mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Populating the edit form with the current payment collector
This commit is contained in:
parent
cbdc81b836
commit
9429af22e2
@ -145,6 +145,7 @@ export default function Edit({
|
|||||||
<Formik
|
<Formik
|
||||||
enableReinitialize
|
enableReinitialize
|
||||||
initialValues={getInitialValues(
|
initialValues={getInitialValues(
|
||||||
|
asset?.nft.owner,
|
||||||
asset?.metadata,
|
asset?.metadata,
|
||||||
asset?.services[0]?.timeout,
|
asset?.services[0]?.timeout,
|
||||||
asset?.accessDetails?.price
|
asset?.accessDetails?.price
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { ReactElement, useEffect } from 'react'
|
import React, { ReactElement, useEffect } from 'react'
|
||||||
import { Field, Form, useField, useFormikContext } from 'formik'
|
import { Field, Form, useFormikContext } from 'formik'
|
||||||
import Input, { InputProps } from '@shared/FormInput'
|
import Input, { InputProps } from '@shared/FormInput'
|
||||||
import FormActions from './FormActions'
|
import FormActions from './FormActions'
|
||||||
import { useAsset } from '@context/Asset'
|
import { useAsset } from '@context/Asset'
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
import { Metadata, ServiceComputeOptions } from '@oceanprotocol/lib'
|
import {
|
||||||
|
Metadata,
|
||||||
|
ServiceComputeOptions,
|
||||||
|
getPaymentCollector
|
||||||
|
} from '@oceanprotocol/lib'
|
||||||
import { secondsToString } from '@utils/ddo'
|
import { secondsToString } from '@utils/ddo'
|
||||||
import { ComputeEditForm, MetadataEditForm } from './_types'
|
import { ComputeEditForm, MetadataEditForm } from './_types'
|
||||||
|
|
||||||
export function getInitialValues(
|
export async function getInitialValues(
|
||||||
|
owner: string,
|
||||||
metadata: Metadata,
|
metadata: Metadata,
|
||||||
timeout: number,
|
timeout: number,
|
||||||
price: string
|
price: string
|
||||||
): Partial<MetadataEditForm> {
|
): Promise<Partial<MetadataEditForm>> {
|
||||||
|
const paymentCollector = await getPaymentCollector(owner)
|
||||||
return {
|
return {
|
||||||
name: metadata?.name,
|
name: metadata?.name,
|
||||||
description: metadata?.description,
|
description: metadata?.description,
|
||||||
@ -15,7 +21,8 @@ export function getInitialValues(
|
|||||||
files: [{ url: '', type: '' }],
|
files: [{ url: '', type: '' }],
|
||||||
timeout: secondsToString(timeout),
|
timeout: secondsToString(timeout),
|
||||||
author: metadata?.author,
|
author: metadata?.author,
|
||||||
tags: metadata?.tags
|
tags: metadata?.tags,
|
||||||
|
paymentCollector
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ export interface MetadataEditForm {
|
|||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
timeout: string
|
timeout: string
|
||||||
|
paymentCollector: string
|
||||||
price?: string
|
price?: string
|
||||||
files: FileInfo[]
|
files: FileInfo[]
|
||||||
links?: FileInfo[]
|
links?: FileInfo[]
|
||||||
|
Loading…
Reference in New Issue
Block a user