From cf0c31fc7b81b97a277c13085b07cf375346a7d9 Mon Sep 17 00:00:00 2001 From: EnzoVezzaro Date: Thu, 13 Oct 2022 09:30:45 -0400 Subject: [PATCH] fix submit button disabled --- .../@shared/FormFields/FilesInput/index.tsx | 11 ++++++++--- src/components/Asset/Edit/_constants.ts | 2 +- src/components/Asset/Edit/_validation.ts | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/@shared/FormFields/FilesInput/index.tsx b/src/components/@shared/FormFields/FilesInput/index.tsx index 33710a9a4..417dbe8bd 100644 --- a/src/components/@shared/FormFields/FilesInput/index.tsx +++ b/src/components/@shared/FormFields/FilesInput/index.tsx @@ -44,14 +44,14 @@ export default function FilesInput(props: InputProps): ReactElement { } function handleClose() { - helpers.setValue(meta.initialValue) helpers.setTouched(false) + helpers.setValue(meta.initialValue) } useEffect(() => { if (field.name === 'links' && asset?.metadata?.links) { handleValidation(null, asset.metadata.links[0]) - } else if (field.name === 'files' && asset?.metadata?.links) { + } else if (field.name === 'files') { getFileDidInfo( asset?.id, asset?.services[0]?.id, @@ -60,7 +60,12 @@ export default function FilesInput(props: InputProps): ReactElement { setHideUrl(true) // setting placeholder for url file to avoid txs for the url file during initializing helpers.setValue([ - { url: 'oceanprotocol.com/placeholder', ...fileDidInfo[0] } + { + url: fileDidInfo[0].valid + ? 'http://oceanprotocol.com/placeholder' + : '', + ...fileDidInfo[0] + } ]) }) } diff --git a/src/components/Asset/Edit/_constants.ts b/src/components/Asset/Edit/_constants.ts index aefafa657..3a1031d41 100644 --- a/src/components/Asset/Edit/_constants.ts +++ b/src/components/Asset/Edit/_constants.ts @@ -11,7 +11,7 @@ export function getInitialValues( name: metadata?.name, description: metadata?.description, price, - links: metadata?.links as any, + links: [{ url: '', type: '' }], files: [{ url: '', type: '' }], timeout: secondsToString(timeout), author: metadata?.author, diff --git a/src/components/Asset/Edit/_validation.ts b/src/components/Asset/Edit/_validation.ts index 52b9faf07..1bb405bcc 100644 --- a/src/components/Asset/Edit/_validation.ts +++ b/src/components/Asset/Edit/_validation.ts @@ -10,8 +10,8 @@ export const validationSchema = Yup.object().shape({ files: Yup.array() .of( Yup.object().shape({ - url: Yup.string().url('Must be a valid URL.'), - valid: Yup.boolean().isTrue() + url: Yup.string().url('Must be a valid URL.').required('Required'), + valid: Yup.boolean().isTrue().required('File must be valid.') }) ) .nullable(),