From cf44ab7f51e7dbfdb4c437ae589bcd649975e042 Mon Sep 17 00:00:00 2001 From: Norbi <37236152+KatunaNorbert@users.noreply.github.com> Date: Thu, 22 Apr 2021 13:55:11 +0300 Subject: [PATCH] Feature/allow changing of fixed rate price (#399) * added price field to edit metadata form * use method for updating price * get exchangeId for setRate function * setRate method update * misc fixes Signed-off-by: mihaisc * revert price Signed-off-by: mihaisc * get correct exchange id Signed-off-by: mihaisc * add price to MetadataEditForm interface * fixed lint error * disable update price on assets with dynamic price * display price input only on fixed price * price input changes * fixed price input displayed when no price is set * review fixes * fixes Co-authored-by: mihaisc Co-authored-by: Norbi --- content/pages/edit.json | 9 ++++++ src/@types/MetaData.d.ts | 1 + .../AssetActions/Edit/FormEditMetadata.tsx | 30 +++++++++++-------- .../organisms/AssetActions/Edit/index.tsx | 23 ++++++++++++-- src/models/FormEditMetadata.ts | 9 ++++-- 5 files changed, 55 insertions(+), 17 deletions(-) diff --git a/content/pages/edit.json b/content/pages/edit.json index 13d6089c5..ac8e21e0d 100644 --- a/content/pages/edit.json +++ b/content/pages/edit.json @@ -20,6 +20,15 @@ "rows": 10, "required": true }, + { + "name": "price", + "label": "New Price", + "type": "number", + "min": "1", + "placeholder": "0", + "help": "Enter a new price.", + "required": true + }, { "name": "links", "label": "Sample file", diff --git a/src/@types/MetaData.d.ts b/src/@types/MetaData.d.ts index 7b8a85ab3..f70e69a0b 100644 --- a/src/@types/MetaData.d.ts +++ b/src/@types/MetaData.d.ts @@ -29,6 +29,7 @@ export interface MetadataEditForm { name: string description: string timeout: string + price?: number links?: string | EditableMetadataLinks[] } diff --git a/src/components/organisms/AssetActions/Edit/FormEditMetadata.tsx b/src/components/organisms/AssetActions/Edit/FormEditMetadata.tsx index cf4b5794c..348b2bb1b 100644 --- a/src/components/organisms/AssetActions/Edit/FormEditMetadata.tsx +++ b/src/components/organisms/AssetActions/Edit/FormEditMetadata.tsx @@ -47,15 +47,17 @@ export default function FormEditMetadata({ data, setShowEdit, setTimeoutStringValue, - values + values, + showPrice }: { data: FormFieldProps[] setShowEdit: (show: boolean) => void setTimeoutStringValue: (value: string) => void values: Partial + showPrice: boolean }): ReactElement { const { accountId } = useWeb3() - const { ocean } = useOcean() + const { ocean, config } = useOcean() const { isValid, validateField, @@ -79,16 +81,20 @@ export default function FormEditMetadata({ return (
- {data.map((field: FormFieldProps) => ( - ) => - handleFieldChange(e, field) - } - /> - ))} + {data.map( + (field: FormFieldProps) => + (!showPrice && field.name === 'price') || ( + ) => + handleFieldChange(e, field) + } + /> + ) + )}