From 006b03148126223e8898be4aa5745eac133351d0 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Thu, 12 Jan 2023 13:40:37 +0000 Subject: [PATCH] Checking if the Provider can be reached and throwwing an error --- .../FormInput/InputElement/FilesInput/index.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/@shared/FormInput/InputElement/FilesInput/index.tsx b/src/components/@shared/FormInput/InputElement/FilesInput/index.tsx index 5376c37d3..023166259 100644 --- a/src/components/@shared/FormInput/InputElement/FilesInput/index.tsx +++ b/src/components/@shared/FormInput/InputElement/FilesInput/index.tsx @@ -1,15 +1,15 @@ -import React, { ReactElement, useEffect, useState } from 'react' +import React, { ReactElement, useState } from 'react' import { useField } from 'formik' import FileInfo from './Info' import UrlInput from '../URLInput' import { InputProps } from '@shared/FormInput' import { getFileInfo } from '@utils/provider' -import { LoggerInstance } from '@oceanprotocol/lib' +import { LoggerInstance, ProviderInstance } from '@oceanprotocol/lib' import { useAsset } from '@context/Asset' import { isGoogleUrl } from '@utils/url/index' export default function FilesInput(props: InputProps): ReactElement { - const [field, meta, helpers] = useField(props.name) + const [field, helpers] = useField(props.name) const [isLoading, setIsLoading] = useState(false) const { asset } = useAsset() @@ -26,6 +26,12 @@ export default function FilesInput(props: InputProps): ReactElement { try { setIsLoading(true) + if (!ProviderInstance.isValidProvider(providerUrl)) { + throw Error( + '✗ Provider cannot be reached, please check status.oceanprotocol.com and try again later.' + ) + } + // TODO: handled on provider if (isGoogleUrl(url)) { throw Error(