mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
package updates
This commit is contained in:
parent
6ac08b6d48
commit
2e407857ff
6
package-lock.json
generated
6
package-lock.json
generated
@ -3987,9 +3987,9 @@
|
||||
"integrity": "sha512-5Oohzno3tnISMYG1jhtHxKMMkcIypTZAPlIoFjE5vDlAW51tyuxwYxBXHYQ2/FLRVFkmUmy5yASKg9zbnKKwQw=="
|
||||
},
|
||||
"@oceanprotocol/lib": {
|
||||
"version": "0.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.1.5.tgz",
|
||||
"integrity": "sha512-feQvrcoLqgQKA4GYfMJrHJAnZDUVslk+Lg2tdR9uWBEpblT+i8yvFdl3AoBRoUddL/5tV6dOKZJ7g/njFTZtmQ==",
|
||||
"version": "0.1.6",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.1.6.tgz",
|
||||
"integrity": "sha512-eFncaLtetef6REKzd2u68fFCVdCfBqwGnsDU9oirMfBrdcGu0VquXtAsEfrnHAkIsCaf97wd1GAZ4Yp1JaXP1g==",
|
||||
"requires": {
|
||||
"@ethereum-navigator/navigator": "^0.5.0",
|
||||
"@oceanprotocol/contracts": "^0.2.3",
|
||||
|
@ -1,5 +1,4 @@
|
||||
import React, { ReactElement } from 'react'
|
||||
import * as Yup from 'yup'
|
||||
import { useNavigate } from '@reach/router'
|
||||
import { toast } from 'react-toastify'
|
||||
import styles from './PublishForm.module.css'
|
||||
@ -10,44 +9,10 @@ import Button from '../../atoms/Button'
|
||||
import { transformPublishFormToMetadata } from './utils'
|
||||
import { FormContent, FormFieldProps } from '../../../@types/Form'
|
||||
import { MetadataPublishForm } from '../../../@types/Metadata'
|
||||
import { File as FileMetadata } from '@oceanprotocol/lib/dist/node/ddo/interfaces/File'
|
||||
import { useSiteMetadata } from '../../../hooks/useSiteMetadata'
|
||||
import { Persist } from 'formik-persist'
|
||||
import Loader from '../../atoms/Loader'
|
||||
import Alert from '../../atoms/Alert'
|
||||
|
||||
const validationSchema = Yup.object().shape<MetadataPublishForm>({
|
||||
// ---- required fields ----
|
||||
name: Yup.string().required('Required'),
|
||||
author: Yup.string().required('Required'),
|
||||
cost: Yup.string().required('Required'),
|
||||
files: Yup.array<FileMetadata>().required('Required').nullable(),
|
||||
description: Yup.string().required('Required'),
|
||||
license: Yup.string().required('Required'),
|
||||
access: Yup.string()
|
||||
.matches(/Compute|Download/g)
|
||||
.required('Required'),
|
||||
termsAndConditions: Yup.boolean().required('Required'),
|
||||
|
||||
// ---- optional fields ----
|
||||
copyrightHolder: Yup.string(),
|
||||
tags: Yup.string(),
|
||||
links: Yup.object<FileMetadata[]>()
|
||||
})
|
||||
|
||||
const initialValues: MetadataPublishForm = {
|
||||
name: undefined,
|
||||
author: undefined,
|
||||
cost: undefined,
|
||||
files: undefined,
|
||||
description: undefined,
|
||||
license: undefined,
|
||||
access: undefined,
|
||||
termsAndConditions: undefined,
|
||||
copyrightHolder: undefined,
|
||||
tags: undefined,
|
||||
links: undefined
|
||||
}
|
||||
import { initialValues, validationSchema } from './validation'
|
||||
|
||||
export default function PublishForm({
|
||||
content
|
||||
@ -65,7 +30,7 @@ export default function PublishForm({
|
||||
const navigate = useNavigate()
|
||||
const { marketAddress } = useSiteMetadata()
|
||||
|
||||
async function handleSubmit(values: MetadataPublishForm) {
|
||||
async function handleSubmit(values: MetadataPublishForm): Promise<void> {
|
||||
console.log(`
|
||||
Collected form values:
|
||||
----------------------
|
||||
|
36
src/components/pages/Publish/validation.ts
Normal file
36
src/components/pages/Publish/validation.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { MetadataPublishForm } from '../../../@types/Metadata'
|
||||
import { File as FileMetadata } from '@oceanprotocol/lib/dist/node/ddo/interfaces/File'
|
||||
import * as Yup from 'yup'
|
||||
|
||||
export const validationSchema = Yup.object().shape<MetadataPublishForm>({
|
||||
// ---- required fields ----
|
||||
name: Yup.string().required('Required'),
|
||||
author: Yup.string().required('Required'),
|
||||
cost: Yup.string().required('Required'),
|
||||
files: Yup.array<FileMetadata>().required('Required').nullable(),
|
||||
description: Yup.string().required('Required'),
|
||||
license: Yup.string().required('Required'),
|
||||
access: Yup.string()
|
||||
.matches(/Compute|Download/g)
|
||||
.required('Required'),
|
||||
termsAndConditions: Yup.boolean().required('Required'),
|
||||
|
||||
// ---- optional fields ----
|
||||
copyrightHolder: Yup.string(),
|
||||
tags: Yup.string(),
|
||||
links: Yup.object<FileMetadata[]>()
|
||||
})
|
||||
|
||||
export const initialValues: MetadataPublishForm = {
|
||||
name: undefined,
|
||||
author: undefined,
|
||||
cost: undefined,
|
||||
files: undefined,
|
||||
description: undefined,
|
||||
license: undefined,
|
||||
access: undefined,
|
||||
termsAndConditions: undefined,
|
||||
copyrightHolder: undefined,
|
||||
tags: undefined,
|
||||
links: undefined
|
||||
}
|
Loading…
Reference in New Issue
Block a user