From 986fd37d3e424b402d0590efff9dbd8af0efacca Mon Sep 17 00:00:00 2001 From: claudiaHash <49017601+claudiaHash@users.noreply.github.com> Date: Mon, 18 Apr 2022 14:39:23 +0300 Subject: [PATCH] Sample file validation in edit form fix (#1351) * fix missing asset provider * comment removed Co-authored-by: ClaudiaHolhos --- src/components/@shared/FormFields/FilesInput/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/@shared/FormFields/FilesInput/index.tsx b/src/components/@shared/FormFields/FilesInput/index.tsx index 5098993e5..527fb1f38 100644 --- a/src/components/@shared/FormFields/FilesInput/index.tsx +++ b/src/components/@shared/FormFields/FilesInput/index.tsx @@ -6,18 +6,22 @@ import { InputProps } from '@shared/FormInput' import { getFileUrlInfo } from '@utils/provider' import { FormPublishData } from 'src/components/Publish/_types' import { LoggerInstance } from '@oceanprotocol/lib' +import { useAsset } from '@context/Asset' export default function FilesInput(props: InputProps): ReactElement { const [field, meta, helpers] = useField(props.name) const [isLoading, setIsLoading] = useState(false) const { values, setFieldError } = useFormikContext() + const { asset } = useAsset() async function handleValidation(e: React.SyntheticEvent, url: string) { // File example 'https://oceanprotocol.com/tech-whitepaper.pdf' e.preventDefault() try { - const providerUrl = values?.services[0].providerUrl.url + const providerUrl = values?.services + ? values?.services[0].providerUrl.url + : asset.services[0].serviceEndpoint setIsLoading(true) const checkedFile = await getFileUrlInfo(url, providerUrl)