1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-15 01:34:57 +01:00

fix empty optional fields

This commit is contained in:
Matthias Kretschmann 2020-09-21 18:18:24 +00:00
parent eb8221d104
commit fbef95a644
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 6 additions and 13 deletions

View File

@ -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

View File

@ -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
}