mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
* split validation / constants * some minor refactor * fix edit form (duplication ErrorMessage) * fix Feedback UI * remove logs * fix empty space when loading total sales * added isTrue to valid * remove hardcoded FileInfo typing in publish and edit * fix more FileInfo typing * fix missing error message on inputs
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { Metadata, ServiceComputeOptions } from '@oceanprotocol/lib'
|
|
import { secondsToString } from '@utils/ddo'
|
|
import { ComputeEditForm, MetadataEditForm } from './_types'
|
|
|
|
export function getInitialValues(
|
|
metadata: Metadata,
|
|
timeout: number,
|
|
price: string
|
|
): Partial<MetadataEditForm> {
|
|
return {
|
|
name: metadata?.name,
|
|
description: metadata?.description,
|
|
price,
|
|
links: metadata?.links as any,
|
|
files: [{ url: '', type: '' }],
|
|
timeout: secondsToString(timeout),
|
|
author: metadata?.author
|
|
}
|
|
}
|
|
|
|
export function getComputeSettingsInitialValues({
|
|
publisherTrustedAlgorithms,
|
|
publisherTrustedAlgorithmPublishers
|
|
}: ServiceComputeOptions): ComputeEditForm {
|
|
const allowAllPublishedAlgorithms = publisherTrustedAlgorithms === null
|
|
const publisherTrustedAlgorithmsForForm = allowAllPublishedAlgorithms
|
|
? null
|
|
: publisherTrustedAlgorithms.map((algo) => algo.did)
|
|
|
|
return {
|
|
allowAllPublishedAlgorithms,
|
|
publisherTrustedAlgorithms: publisherTrustedAlgorithmsForForm,
|
|
publisherTrustedAlgorithmPublishers
|
|
}
|
|
}
|