1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

metadata tweaks

This commit is contained in:
Matthias Kretschmann 2021-11-04 11:14:48 +01:00
parent 72605b5341
commit 0fb4e630c1
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 22 additions and 21 deletions

View File

@ -5,8 +5,12 @@ import { wizardSteps } from '../_constants'
import styles from './index.module.css'
export default function Navigation(): ReactElement {
const { values, setFieldValue }: FormikContextType<FormPublishData> =
useFormikContext()
const {
values,
errors,
touched,
setFieldValue
}: FormikContextType<FormPublishData> = useFormikContext()
function handleStepClick(step: number) {
setFieldValue('step', step)

View File

@ -34,8 +34,8 @@ export const wizardSteps: StepContent[] = [
export const initialValues: Partial<FormPublishData> = {
step: 1,
type: 'dataset',
metadata: {
type: 'dataset',
name: '',
author: '',
description: '',
@ -69,6 +69,9 @@ export const initialValues: Partial<FormPublishData> = {
}
const validationMetadata = {
type: Yup.string()
.matches(/dataset|algorithm/g, { excludeEmptyString: true })
.required('Required'),
name: Yup.string()
.min(4, (param) => `Title must be at least ${param.min} characters`)
.required('Required'),
@ -85,16 +88,11 @@ const validationService = {
.required('Enter a valid URL and click "ADD FILE"')
.nullable(),
links: Yup.array<FileMetadata[]>().nullable(),
dataTokenOptions: Yup.object()
.shape({
name: Yup.string(),
symbol: Yup.string()
})
.required('Required'),
dataTokenOptions: Yup.object().shape({
name: Yup.string(),
symbol: Yup.string()
}),
timeout: Yup.string().required('Required'),
type: Yup.string()
.matches(/Dataset|Algorithm/g, { excludeEmptyString: true })
.required('Required'),
access: Yup.string()
.matches(/Compute|Download/g, { excludeEmptyString: true })
.required('Required'),
@ -123,13 +121,13 @@ const validationPricing = {
.nullable()
}
export const validationSchema: Yup.SchemaOf<FormPublishData> = Yup.object()
.shape({
metadata: Yup.object().shape(validationMetadata),
services: Yup.array().of(Yup.object().shape(validationService)),
pricing: Yup.object().shape(validationPricing)
})
.defined()
// export const validationSchema: Yup.SchemaOf<FormPublishData> =
export const validationSchema: Yup.SchemaOf<any> = Yup.object().shape({
step: Yup.number(),
metadata: Yup.object().shape(validationMetadata),
services: Yup.array().of(Yup.object().shape(validationService)),
pricing: Yup.object().shape(validationPricing)
})
// export const validationSchemaAlgo: Yup.SchemaOf<MetadataPublishFormAlgorithm> =
// Yup.object()

View File

@ -16,9 +16,8 @@ export interface FormPublishService {
export interface FormPublishData {
step: number
steps: number
type: 'dataset' | 'algorithm'
metadata: {
type: 'dataset' | 'algorithm' | string
name: string
description: string
author: string