mirror of
https://github.com/oceanprotocol/market.git
synced 2024-11-15 09:44:53 +01:00
fix empty optional fields
This commit is contained in:
parent
eb8221d104
commit
fbef95a644
@ -6,12 +6,8 @@ import FileInput from './Input'
|
||||
import { getFileInfo } from '../../../../utils'
|
||||
import { InputProps } from '../../../atoms/Input'
|
||||
|
||||
interface Values {
|
||||
url: string
|
||||
}
|
||||
|
||||
export default function FilesInput(props: InputProps): ReactElement {
|
||||
const [field, meta, helpers] = useField(props)
|
||||
const [field, meta, helpers] = useField(props.name)
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
|
||||
async function handleButtonClick(e: React.SyntheticEvent, url: string) {
|
||||
@ -36,7 +32,7 @@ export default function FilesInput(props: InputProps): ReactElement {
|
||||
|
||||
return (
|
||||
<>
|
||||
{field && typeof field.value === 'object' ? (
|
||||
{field?.value && field.value[0] && typeof field.value === 'object' ? (
|
||||
<FileInfo file={field.value[0]} removeItem={removeItem} />
|
||||
) : (
|
||||
<FileInput
|
||||
|
@ -31,12 +31,12 @@ export const validationSchema = Yup.object().shape<MetadataPublishForm>({
|
||||
termsAndConditions: Yup.boolean().required('Required'),
|
||||
|
||||
// ---- optional fields ----
|
||||
copyrightHolder: Yup.string(),
|
||||
tags: Yup.string(),
|
||||
copyrightHolder: Yup.string().nullable(),
|
||||
tags: Yup.string().nullable(),
|
||||
links: Yup.object<FileMetadata[]>().nullable()
|
||||
})
|
||||
|
||||
export const initialValues: MetadataPublishForm = {
|
||||
export const initialValues: Partial<MetadataPublishForm> = {
|
||||
name: '',
|
||||
author: '',
|
||||
price: {
|
||||
@ -50,8 +50,5 @@ export const initialValues: MetadataPublishForm = {
|
||||
description: '',
|
||||
license: '',
|
||||
access: '',
|
||||
termsAndConditions: false,
|
||||
copyrightHolder: '',
|
||||
tags: '',
|
||||
links: ''
|
||||
termsAndConditions: false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user