1
0
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:
Jamie Hewitt 2022-11-15 10:05:12 +03:00
parent cbdc81b836
commit 9429af22e2
4 changed files with 14 additions and 5 deletions

View File

@ -145,6 +145,7 @@ export default function Edit({
<Formik
enableReinitialize
initialValues={getInitialValues(
asset?.nft.owner,
asset?.metadata,
asset?.services[0]?.timeout,
asset?.accessDetails?.price

View File

@ -1,5 +1,5 @@
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 FormActions from './FormActions'
import { useAsset } from '@context/Asset'

View File

@ -1,12 +1,18 @@
import { Metadata, ServiceComputeOptions } from '@oceanprotocol/lib'
import {
Metadata,
ServiceComputeOptions,
getPaymentCollector
} from '@oceanprotocol/lib'
import { secondsToString } from '@utils/ddo'
import { ComputeEditForm, MetadataEditForm } from './_types'
export function getInitialValues(
export async function getInitialValues(
owner: string,
metadata: Metadata,
timeout: number,
price: string
): Partial<MetadataEditForm> {
): Promise<Partial<MetadataEditForm>> {
const paymentCollector = await getPaymentCollector(owner)
return {
name: metadata?.name,
description: metadata?.description,
@ -15,7 +21,8 @@ export function getInitialValues(
files: [{ url: '', type: '' }],
timeout: secondsToString(timeout),
author: metadata?.author,
tags: metadata?.tags
tags: metadata?.tags,
paymentCollector
}
}

View File

@ -3,6 +3,7 @@ export interface MetadataEditForm {
name: string
description: string
timeout: string
paymentCollector: string
price?: string
files: FileInfo[]
links?: FileInfo[]