mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
32 lines
812 B
TypeScript
32 lines
812 B
TypeScript
import React, { ReactElement } from 'react'
|
|
import isUrl from 'is-url-superb'
|
|
import Button from '../../atoms/Button'
|
|
import Input from '../../atoms/Input'
|
|
import { useField, FormikProps } from 'formik'
|
|
import { File } from '@oceanprotocol/squid'
|
|
|
|
export default function FileInput({
|
|
handleButtonClick,
|
|
...props
|
|
}: {
|
|
handleButtonClick(e: React.SyntheticEvent, data: string): void
|
|
props: FormikProps<File>
|
|
}): ReactElement {
|
|
const [field, meta, helpers] = useField(props)
|
|
console.log(field)
|
|
|
|
return (
|
|
<>
|
|
<Input type="url" name="url" placeholder="e.g." {...field} />
|
|
|
|
<Button
|
|
size="small"
|
|
onClick={(e: React.SyntheticEvent) => handleButtonClick(e, field.value)}
|
|
// disabled={!isUrl(field && field.value)}
|
|
>
|
|
Add File
|
|
</Button>
|
|
</>
|
|
)
|
|
}
|