Sample file validation in edit form fix (#1351)

* fix missing asset provider

* comment removed

Co-authored-by: ClaudiaHolhos <claudia@oceanprotocol.com>
This commit is contained in:
claudiaHash 2022-04-18 14:39:23 +03:00 committed by GitHub
parent 967b869b02
commit 986fd37d3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -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<FormPublishData>()
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)