mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
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:
parent
967b869b02
commit
986fd37d3e
@ -6,18 +6,22 @@ import { InputProps } from '@shared/FormInput'
|
|||||||
import { getFileUrlInfo } from '@utils/provider'
|
import { getFileUrlInfo } from '@utils/provider'
|
||||||
import { FormPublishData } from 'src/components/Publish/_types'
|
import { FormPublishData } from 'src/components/Publish/_types'
|
||||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||||
|
import { useAsset } from '@context/Asset'
|
||||||
|
|
||||||
export default function FilesInput(props: InputProps): ReactElement {
|
export default function FilesInput(props: InputProps): ReactElement {
|
||||||
const [field, meta, helpers] = useField(props.name)
|
const [field, meta, helpers] = useField(props.name)
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
const { values, setFieldError } = useFormikContext<FormPublishData>()
|
const { values, setFieldError } = useFormikContext<FormPublishData>()
|
||||||
|
const { asset } = useAsset()
|
||||||
|
|
||||||
async function handleValidation(e: React.SyntheticEvent, url: string) {
|
async function handleValidation(e: React.SyntheticEvent, url: string) {
|
||||||
// File example 'https://oceanprotocol.com/tech-whitepaper.pdf'
|
// File example 'https://oceanprotocol.com/tech-whitepaper.pdf'
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const providerUrl = values?.services[0].providerUrl.url
|
const providerUrl = values?.services
|
||||||
|
? values?.services[0].providerUrl.url
|
||||||
|
: asset.services[0].serviceEndpoint
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
const checkedFile = await getFileUrlInfo(url, providerUrl)
|
const checkedFile = await getFileUrlInfo(url, providerUrl)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user