fix: typeerror in the postage stamps form (#137)

This commit is contained in:
Vojtech Simetka
2021-06-03 13:18:58 +02:00
committed by GitHub
parent 3bcf2ac688
commit 465df17741
+4 -3
View File
@@ -63,7 +63,8 @@ export default function FormDialog({ label }: Props): ReactElement {
initialValues={initialFormValues} initialValues={initialFormValues}
onSubmit={async (values: FormValues, actions: FormikHelpers<FormValues>) => { onSubmit={async (values: FormValues, actions: FormikHelpers<FormValues>) => {
try { try {
if (!values.depth) return // This is really just a typeguard, the validation pretty much guarantees these will have the right values
if (!values.depth || !values.amount) return
const amount = BigInt(values.amount) const amount = BigInt(values.amount)
const depth = Number.parseInt(values.depth) const depth = Number.parseInt(values.depth)
@@ -105,7 +106,7 @@ export default function FormDialog({ label }: Props): ReactElement {
return errors return errors
}} }}
> >
{({ submitForm, isValid, isSubmitting }) => ( {({ submitForm, isValid, isSubmitting, values }) => (
<Form> <Form>
<Button variant="outlined" color="primary" onClick={handleClickOpen}> <Button variant="outlined" color="primary" onClick={handleClickOpen}>
{label || 'Buy Postage Stamp'} {label || 'Buy Postage Stamp'}
@@ -140,7 +141,7 @@ export default function FormDialog({ label }: Props): ReactElement {
<div className={classes.wrapper}> <div className={classes.wrapper}>
<Button <Button
color="primary" color="primary"
disabled={isSubmitting || !isValid} disabled={isSubmitting || !isValid || !values.amount || !values.depth}
type="submit" type="submit"
variant="contained" variant="contained"
onClick={submitForm} onClick={submitForm}