1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-14 17:24:51 +01:00

reset form after submit

This commit is contained in:
Matthias Kretschmann 2020-08-05 15:23:54 +02:00
parent 9359396aa9
commit 6271f46918
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -21,7 +21,10 @@ export default function PublishPage({
const { publish, publishError } = usePublish()
const navigate = useNavigate()
async function handleSubmit(values: MetadataPublishForm): Promise<void> {
async function handleSubmit(
values: MetadataPublishForm,
resetForm: () => void
): Promise<void> {
console.log(`
Collected form values:
----------------------
@ -69,7 +72,9 @@ export default function PublishPage({
// User feedback and redirect to new asset detail page
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
navigate(`/asset/${ddo.id}`)
@ -85,8 +90,8 @@ export default function PublishPage({
initialValues={initialValues}
initialStatus="empty"
validationSchema={validationSchema}
onSubmit={async (values, { setSubmitting }) => {
await handleSubmit(values)
onSubmit={async (values, { setSubmitting, resetForm }) => {
await handleSubmit(values, resetForm)
setSubmitting(false)
}}
>