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' import styles from './index.module.css'
export default function Navigation(): ReactElement { export default function Navigation(): ReactElement {
const { values, setFieldValue }: FormikContextType<FormPublishData> = const {
useFormikContext() values,
errors,
touched,
setFieldValue
}: FormikContextType<FormPublishData> = useFormikContext()
function handleStepClick(step: number) { function handleStepClick(step: number) {
setFieldValue('step', step) setFieldValue('step', step)

View File

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

View File

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