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=="
|
"integrity": "sha512-5Oohzno3tnISMYG1jhtHxKMMkcIypTZAPlIoFjE5vDlAW51tyuxwYxBXHYQ2/FLRVFkmUmy5yASKg9zbnKKwQw=="
|
||||||
},
|
},
|
||||||
"@oceanprotocol/lib": {
|
"@oceanprotocol/lib": {
|
||||||
"version": "0.1.5",
|
"version": "0.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.1.6.tgz",
|
||||||
"integrity": "sha512-feQvrcoLqgQKA4GYfMJrHJAnZDUVslk+Lg2tdR9uWBEpblT+i8yvFdl3AoBRoUddL/5tV6dOKZJ7g/njFTZtmQ==",
|
"integrity": "sha512-eFncaLtetef6REKzd2u68fFCVdCfBqwGnsDU9oirMfBrdcGu0VquXtAsEfrnHAkIsCaf97wd1GAZ4Yp1JaXP1g==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethereum-navigator/navigator": "^0.5.0",
|
"@ethereum-navigator/navigator": "^0.5.0",
|
||||||
"@oceanprotocol/contracts": "^0.2.3",
|
"@oceanprotocol/contracts": "^0.2.3",
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import React, { ReactElement } from 'react'
|
import React, { ReactElement } from 'react'
|
||||||
import * as Yup from 'yup'
|
|
||||||
import { useNavigate } from '@reach/router'
|
import { useNavigate } from '@reach/router'
|
||||||
import { toast } from 'react-toastify'
|
import { toast } from 'react-toastify'
|
||||||
import styles from './PublishForm.module.css'
|
import styles from './PublishForm.module.css'
|
||||||
@ -10,44 +9,10 @@ import Button from '../../atoms/Button'
|
|||||||
import { transformPublishFormToMetadata } from './utils'
|
import { transformPublishFormToMetadata } from './utils'
|
||||||
import { FormContent, FormFieldProps } from '../../../@types/Form'
|
import { FormContent, FormFieldProps } from '../../../@types/Form'
|
||||||
import { MetadataPublishForm } from '../../../@types/Metadata'
|
import { MetadataPublishForm } from '../../../@types/Metadata'
|
||||||
import { File as FileMetadata } from '@oceanprotocol/lib/dist/node/ddo/interfaces/File'
|
|
||||||
import { useSiteMetadata } from '../../../hooks/useSiteMetadata'
|
import { useSiteMetadata } from '../../../hooks/useSiteMetadata'
|
||||||
import { Persist } from 'formik-persist'
|
import { Persist } from 'formik-persist'
|
||||||
import Loader from '../../atoms/Loader'
|
import Loader from '../../atoms/Loader'
|
||||||
import Alert from '../../atoms/Alert'
|
import { initialValues, validationSchema } from './validation'
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function PublishForm({
|
export default function PublishForm({
|
||||||
content
|
content
|
||||||
@ -65,7 +30,7 @@ export default function PublishForm({
|
|||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const { marketAddress } = useSiteMetadata()
|
const { marketAddress } = useSiteMetadata()
|
||||||
|
|
||||||
async function handleSubmit(values: MetadataPublishForm) {
|
async function handleSubmit(values: MetadataPublishForm): Promise<void> {
|
||||||
console.log(`
|
console.log(`
|
||||||
Collected form values:
|
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