mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
fixed reset form & cover flow where algorithm form is clear
This commit is contained in:
parent
dca5b9f56c
commit
90787e9031
@ -7,6 +7,8 @@ import Input from '../../atoms/Input'
|
|||||||
import Button from '../../atoms/Button'
|
import Button from '../../atoms/Button'
|
||||||
import { FormContent, FormFieldProps } from '../../../@types/Form'
|
import { FormContent, FormFieldProps } from '../../../@types/Form'
|
||||||
import { MetadataPublishFormAlgorithm } from '../../../@types/MetaData'
|
import { MetadataPublishFormAlgorithm } from '../../../@types/MetaData'
|
||||||
|
import { initialValues as initialValuesAlgorithm } from '../../../models/FormAlgoPublish'
|
||||||
|
|
||||||
import stylesIndex from './index.module.css'
|
import stylesIndex from './index.module.css'
|
||||||
|
|
||||||
const query = graphql`
|
const query = graphql`
|
||||||
@ -115,7 +117,10 @@ export default function FormPublish(): ReactElement {
|
|||||||
|
|
||||||
const resetFormAndClearStorage = (e: FormEvent<Element>) => {
|
const resetFormAndClearStorage = (e: FormEvent<Element>) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
resetForm({ values: initialValues, status: 'empty' })
|
resetForm({
|
||||||
|
values: initialValuesAlgorithm as MetadataPublishFormAlgorithm,
|
||||||
|
status: 'empty'
|
||||||
|
})
|
||||||
setStatus('empty')
|
setStatus('empty')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import Input from '../../atoms/Input'
|
|||||||
import Button from '../../atoms/Button'
|
import Button from '../../atoms/Button'
|
||||||
import { FormContent, FormFieldProps } from '../../../@types/Form'
|
import { FormContent, FormFieldProps } from '../../../@types/Form'
|
||||||
import { MetadataPublishFormDataset } from '../../../@types/MetaData'
|
import { MetadataPublishFormDataset } from '../../../@types/MetaData'
|
||||||
|
import { initialValues as initialValuesDataset } from '../../../models/FormAlgoPublish'
|
||||||
import stylesIndex from './index.module.css'
|
import stylesIndex from './index.module.css'
|
||||||
|
|
||||||
const query = graphql`
|
const query = graphql`
|
||||||
@ -73,7 +74,10 @@ export default function FormPublish(): ReactElement {
|
|||||||
|
|
||||||
const resetFormAndClearStorage = (e: FormEvent<Element>) => {
|
const resetFormAndClearStorage = (e: FormEvent<Element>) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
resetForm({ values: initialValues, status: 'empty' })
|
resetForm({
|
||||||
|
values: initialValuesDataset as MetadataPublishFormDataset,
|
||||||
|
status: 'empty'
|
||||||
|
})
|
||||||
setStatus('empty')
|
setStatus('empty')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { ReactElement, useState, useEffect } from 'react'
|
import React, { ReactElement, useState, useEffect } from 'react'
|
||||||
import { Formik } from 'formik'
|
import { Formik, FormikState } from 'formik'
|
||||||
import { usePublish, useOcean } from '@oceanprotocol/react'
|
import { usePublish, useOcean } from '@oceanprotocol/react'
|
||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
import FormPublish from './FormPublish'
|
import FormPublish from './FormPublish'
|
||||||
@ -75,10 +75,20 @@ export default function PublishPage({
|
|||||||
const [did, setDid] = useState<string>()
|
const [did, setDid] = useState<string>()
|
||||||
const [algoInitialValues, setAlgoInitialValues] = useState<
|
const [algoInitialValues, setAlgoInitialValues] = useState<
|
||||||
Partial<MetadataPublishFormAlgorithm>
|
Partial<MetadataPublishFormAlgorithm>
|
||||||
>(initialValuesAlgorithm)
|
>(
|
||||||
|
(localStorage.getItem('ocean-publish-form-algorithms') &&
|
||||||
|
(JSON.parse(localStorage.getItem('ocean-publish-form-algorithms'))
|
||||||
|
.initialValues as MetadataPublishFormAlgorithm)) ||
|
||||||
|
initialValuesAlgorithm
|
||||||
|
)
|
||||||
const [datasetInitialValues, setdatasetInitialValues] = useState<
|
const [datasetInitialValues, setdatasetInitialValues] = useState<
|
||||||
Partial<MetadataPublishFormDataset>
|
Partial<MetadataPublishFormDataset>
|
||||||
>(initialValues)
|
>(
|
||||||
|
(localStorage.getItem('ocean-publish-form-datasets') &&
|
||||||
|
(JSON.parse(localStorage.getItem('ocean-publish-form-datasets'))
|
||||||
|
.initialValues as MetadataPublishFormDataset)) ||
|
||||||
|
initialValues
|
||||||
|
)
|
||||||
const [publishType, setPublishType] = useState<MetadataMain['type']>(
|
const [publishType, setPublishType] = useState<MetadataMain['type']>(
|
||||||
'dataset'
|
'dataset'
|
||||||
)
|
)
|
||||||
@ -93,7 +103,9 @@ export default function PublishPage({
|
|||||||
|
|
||||||
async function handleSubmit(
|
async function handleSubmit(
|
||||||
values: Partial<MetadataPublishFormDataset>,
|
values: Partial<MetadataPublishFormDataset>,
|
||||||
resetForm: () => void
|
resetForm: (
|
||||||
|
nextState?: Partial<FormikState<Partial<MetadataPublishFormDataset>>>
|
||||||
|
) => void
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const metadata = transformPublishFormToMetadata(values)
|
const metadata = transformPublishFormToMetadata(values)
|
||||||
const timeout = mapTimeoutStringToSeconds(values.timeout)
|
const timeout = mapTimeoutStringToSeconds(values.timeout)
|
||||||
@ -127,7 +139,10 @@ export default function PublishPage({
|
|||||||
setSuccess(
|
setSuccess(
|
||||||
'🎉 Successfully published. 🎉 Now create a price on your data set.'
|
'🎉 Successfully published. 🎉 Now create a price on your data set.'
|
||||||
)
|
)
|
||||||
resetForm()
|
resetForm({
|
||||||
|
values: initialValues as MetadataPublishFormDataset,
|
||||||
|
status: 'empty'
|
||||||
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError(error.message)
|
setError(error.message)
|
||||||
Logger.error(error.message)
|
Logger.error(error.message)
|
||||||
@ -136,7 +151,9 @@ export default function PublishPage({
|
|||||||
|
|
||||||
async function handleAlgorithmSubmit(
|
async function handleAlgorithmSubmit(
|
||||||
values: Partial<MetadataPublishFormAlgorithm>,
|
values: Partial<MetadataPublishFormAlgorithm>,
|
||||||
resetForm: () => void
|
resetForm: (
|
||||||
|
nextState?: Partial<FormikState<Partial<MetadataPublishFormAlgorithm>>>
|
||||||
|
) => void
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const metadata = transformPublishAlgorithmFormToMetadata(values)
|
const metadata = transformPublishAlgorithmFormToMetadata(values)
|
||||||
|
|
||||||
@ -160,7 +177,10 @@ export default function PublishPage({
|
|||||||
setSuccess(
|
setSuccess(
|
||||||
'🎉 Successfully published. 🎉 Now create a price for your algorithm.'
|
'🎉 Successfully published. 🎉 Now create a price for your algorithm.'
|
||||||
)
|
)
|
||||||
resetForm()
|
resetForm({
|
||||||
|
values: initialValuesAlgorithm as MetadataPublishFormAlgorithm,
|
||||||
|
status: 'empty'
|
||||||
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError(error.message)
|
setError(error.message)
|
||||||
Logger.error(error.message)
|
Logger.error(error.message)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user