From 95199054f86d515a9ff240efa0fd6ea1a628afc2 Mon Sep 17 00:00:00 2001 From: EnzoVezzaro Date: Mon, 15 Aug 2022 09:02:54 -0400 Subject: [PATCH] adding links validation in edit form --- src/components/@shared/FormFields/FilesInput/index.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/@shared/FormFields/FilesInput/index.tsx b/src/components/@shared/FormFields/FilesInput/index.tsx index 527fb1f38..bc903c03c 100644 --- a/src/components/@shared/FormFields/FilesInput/index.tsx +++ b/src/components/@shared/FormFields/FilesInput/index.tsx @@ -1,4 +1,4 @@ -import React, { ReactElement, useState } from 'react' +import React, { ReactElement, useEffect, useState } from 'react' import { useField, useFormikContext } from 'formik' import FileInfo from './Info' import UrlInput from '../URLInput' @@ -16,7 +16,7 @@ export default function FilesInput(props: InputProps): ReactElement { async function handleValidation(e: React.SyntheticEvent, url: string) { // File example 'https://oceanprotocol.com/tech-whitepaper.pdf' - e.preventDefault() + e?.preventDefault() try { const providerUrl = values?.services @@ -47,6 +47,12 @@ export default function FilesInput(props: InputProps): ReactElement { helpers.setTouched(false) } + useEffect(() => { + if (field.name === 'links' && asset?.metadata?.links) { + handleValidation(null, asset.metadata.links[0]) + } + }, []) + return ( <> {field?.value?.[0]?.valid === true ? (