mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
change publish type from data to dataset
This commit is contained in:
parent
18cd6b6f01
commit
4088a790fb
@ -5,12 +5,13 @@ import Button from '../../atoms/Button'
|
||||
|
||||
const cx = classNames.bind(styles)
|
||||
|
||||
const publishTypes = [
|
||||
{ display: 'data', value: 'data' },
|
||||
{ display: 'algorithms', value: 'algorithms' }
|
||||
]
|
||||
export const TypeOfPublish = {
|
||||
dataset: 'dataset',
|
||||
algorithm: 'algorithm'
|
||||
} as const
|
||||
type TypeOfPublish = typeof TypeOfPublish[keyof typeof TypeOfPublish]
|
||||
|
||||
export default function PublishType({
|
||||
export function PublishType({
|
||||
type,
|
||||
setType
|
||||
}: {
|
||||
@ -18,14 +19,14 @@ export default function PublishType({
|
||||
setType: React.Dispatch<React.SetStateAction<string>>
|
||||
}): ReactElement {
|
||||
useEffect(() => {
|
||||
setType(publishTypes[0].value)
|
||||
setType(TypeOfPublish.dataset)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div>
|
||||
{publishTypes.map((e, index) => {
|
||||
{Object.keys(TypeOfPublish).map((key, index) => {
|
||||
const tabElement = cx({
|
||||
[styles.selected]: e.value === type,
|
||||
[styles.selected]: key === type,
|
||||
[styles.tabElement]: true
|
||||
})
|
||||
return (
|
||||
@ -35,10 +36,10 @@ export default function PublishType({
|
||||
key={index}
|
||||
className={tabElement}
|
||||
onClick={async () => {
|
||||
setType(e.value)
|
||||
setType(key)
|
||||
}}
|
||||
>
|
||||
{e.display}
|
||||
{key}
|
||||
</Button>
|
||||
)
|
||||
})}
|
||||
|
@ -4,7 +4,7 @@ import { usePublish, useOcean } from '@oceanprotocol/react'
|
||||
import styles from './index.module.css'
|
||||
import FormPublish from './FormPublish'
|
||||
import FormAlgoPublish from './FormAlgoPublish'
|
||||
import PublishType from './PublishType'
|
||||
import { PublishType, TypeOfPublish } from './PublishType'
|
||||
import Web3Feedback from '../../molecules/Wallet/Feedback'
|
||||
import { FormContent } from '../../../@types/Form'
|
||||
import { initialValues, validationSchema } from '../../../models/FormPublish'
|
||||
@ -55,7 +55,7 @@ export default function PublishPage({
|
||||
const hasFeedback = isLoading || error || success
|
||||
|
||||
useEffect(() => {
|
||||
publishType === 'data'
|
||||
publishType === TypeOfPublish.dataset
|
||||
? setTitle('Publishing Data Set')
|
||||
: setTitle('Publishing Algorithm')
|
||||
}, [publishType])
|
||||
@ -136,17 +136,21 @@ export default function PublishPage({
|
||||
return isInPurgatory && purgatoryData ? null : (
|
||||
<Formik
|
||||
initialValues={
|
||||
publishType === 'data' ? initialValues : initialValuesAlgorithm
|
||||
publishType === TypeOfPublish.dataset
|
||||
? initialValues
|
||||
: initialValuesAlgorithm
|
||||
}
|
||||
initialStatus="empty"
|
||||
validationSchema={
|
||||
publishType === 'data' ? validationSchema : validationSchemaAlgorithm
|
||||
publishType === TypeOfPublish.dataset
|
||||
? validationSchema
|
||||
: validationSchemaAlgorithm
|
||||
}
|
||||
onSubmit={async (values, { resetForm }) => {
|
||||
// move user's focus to top of screen
|
||||
window.scrollTo({ top: 0, left: 0, behavior: 'smooth' })
|
||||
// kick off publishing
|
||||
publishType === 'data'
|
||||
publishType === TypeOfPublish.dataset
|
||||
? await handleSubmit(values, resetForm)
|
||||
: await handleAlgorithmSubmit(values, resetForm)
|
||||
}}
|
||||
@ -176,7 +180,7 @@ export default function PublishPage({
|
||||
className={styles.alert}
|
||||
/>
|
||||
<article className={styles.grid}>
|
||||
{publishType === 'data' ? (
|
||||
{publishType === TypeOfPublish.dataset ? (
|
||||
<FormPublish content={content.form} />
|
||||
) : (
|
||||
<FormAlgoPublish content={contentAlgoPublish.form} />
|
||||
@ -184,7 +188,7 @@ export default function PublishPage({
|
||||
|
||||
<aside>
|
||||
<div className={styles.sticky}>
|
||||
{publishType === 'data' ? (
|
||||
{publishType === TypeOfPublish.dataset ? (
|
||||
<MetadataPreview values={values} />
|
||||
) : (
|
||||
<MetadataAlgorithmPreview values={values} />
|
||||
|
Loading…
Reference in New Issue
Block a user