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 { getFileInfo } from '../../../../utils'
|
||||||
import { InputProps } from '../../../atoms/Input'
|
import { InputProps } from '../../../atoms/Input'
|
||||||
|
|
||||||
interface Values {
|
|
||||||
url: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function FilesInput(props: InputProps): ReactElement {
|
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)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
|
|
||||||
async function handleButtonClick(e: React.SyntheticEvent, url: string) {
|
async function handleButtonClick(e: React.SyntheticEvent, url: string) {
|
||||||
@ -36,7 +32,7 @@ export default function FilesInput(props: InputProps): ReactElement {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{field && typeof field.value === 'object' ? (
|
{field?.value && field.value[0] && typeof field.value === 'object' ? (
|
||||||
<FileInfo file={field.value[0]} removeItem={removeItem} />
|
<FileInfo file={field.value[0]} removeItem={removeItem} />
|
||||||
) : (
|
) : (
|
||||||
<FileInput
|
<FileInput
|
||||||
|
@ -31,12 +31,12 @@ export const validationSchema = Yup.object().shape<MetadataPublishForm>({
|
|||||||
termsAndConditions: Yup.boolean().required('Required'),
|
termsAndConditions: Yup.boolean().required('Required'),
|
||||||
|
|
||||||
// ---- optional fields ----
|
// ---- optional fields ----
|
||||||
copyrightHolder: Yup.string(),
|
copyrightHolder: Yup.string().nullable(),
|
||||||
tags: Yup.string(),
|
tags: Yup.string().nullable(),
|
||||||
links: Yup.object<FileMetadata[]>().nullable()
|
links: Yup.object<FileMetadata[]>().nullable()
|
||||||
})
|
})
|
||||||
|
|
||||||
export const initialValues: MetadataPublishForm = {
|
export const initialValues: Partial<MetadataPublishForm> = {
|
||||||
name: '',
|
name: '',
|
||||||
author: '',
|
author: '',
|
||||||
price: {
|
price: {
|
||||||
@ -50,8 +50,5 @@ export const initialValues: MetadataPublishForm = {
|
|||||||
description: '',
|
description: '',
|
||||||
license: '',
|
license: '',
|
||||||
access: '',
|
access: '',
|
||||||
termsAndConditions: false,
|
termsAndConditions: false
|
||||||
copyrightHolder: '',
|
|
||||||
tags: '',
|
|
||||||
links: ''
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user