mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
adding links validation in edit form
This commit is contained in:
parent
4d119467a4
commit
95199054f8
@ -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 ? (
|
||||
|
Loading…
Reference in New Issue
Block a user