mirror of
https://github.com/oceanprotocol/market.git
synced 2024-11-15 01:34:57 +01:00
reset form after submit
This commit is contained in:
parent
9359396aa9
commit
6271f46918
@ -21,7 +21,10 @@ export default function PublishPage({
|
|||||||
const { publish, publishError } = usePublish()
|
const { publish, publishError } = usePublish()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
|
||||||
async function handleSubmit(values: MetadataPublishForm): Promise<void> {
|
async function handleSubmit(
|
||||||
|
values: MetadataPublishForm,
|
||||||
|
resetForm: () => void
|
||||||
|
): Promise<void> {
|
||||||
console.log(`
|
console.log(`
|
||||||
Collected form values:
|
Collected form values:
|
||||||
----------------------
|
----------------------
|
||||||
@ -69,7 +72,9 @@ export default function PublishPage({
|
|||||||
// User feedback and redirect to new asset detail page
|
// User feedback and redirect to new asset detail page
|
||||||
ddo && toast.success('Asset created successfully.')
|
ddo && toast.success('Asset created successfully.')
|
||||||
|
|
||||||
// TODO: reset form state and make sure persistant form in localStorage is cleared
|
// reset form state
|
||||||
|
// TODO: verify persistant form in localStorage is cleared with it too
|
||||||
|
resetForm()
|
||||||
|
|
||||||
// Go to new asset detail page
|
// Go to new asset detail page
|
||||||
navigate(`/asset/${ddo.id}`)
|
navigate(`/asset/${ddo.id}`)
|
||||||
@ -85,8 +90,8 @@ export default function PublishPage({
|
|||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
initialStatus="empty"
|
initialStatus="empty"
|
||||||
validationSchema={validationSchema}
|
validationSchema={validationSchema}
|
||||||
onSubmit={async (values, { setSubmitting }) => {
|
onSubmit={async (values, { setSubmitting, resetForm }) => {
|
||||||
await handleSubmit(values)
|
await handleSubmit(values, resetForm)
|
||||||
setSubmitting(false)
|
setSubmitting(false)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user