diff --git a/client/src/containers/Purchases/PaymentMades/PaymentMadeFloatingActions.js b/client/src/containers/Purchases/PaymentMades/PaymentMadeFloatingActions.js index 1fe38e7d2..cc29ef9e1 100644 --- a/client/src/containers/Purchases/PaymentMades/PaymentMadeFloatingActions.js +++ b/client/src/containers/Purchases/PaymentMades/PaymentMadeFloatingActions.js @@ -45,6 +45,7 @@ export default function PaymentMadeFloatingActions({ onSubmitForm(); saveInvoke(onSubmitClick, event, { redirect: false, + resetForm: true, }); }; diff --git a/client/src/containers/Purchases/PaymentMades/PaymentMadeForm.js b/client/src/containers/Purchases/PaymentMades/PaymentMadeForm.js index a75a3a778..f1ee4cf88 100644 --- a/client/src/containers/Purchases/PaymentMades/PaymentMadeForm.js +++ b/client/src/containers/Purchases/PaymentMades/PaymentMadeForm.js @@ -156,13 +156,14 @@ function PaymentMadeForm({ intent: Intent.SUCCESS, }); setSubmitting(false); - // resetForm(); - changePageSubtitle(''); + // changePageSubtitle(''); if (submitPayload.redirect) { history.push('/payment-mades'); } - + if (submitPayload.resetForm) { + resetForm(); + } }; const onError = (errors) => { @@ -193,6 +194,7 @@ function PaymentMadeForm({ values, handleSubmit, isSubmitting, + resetForm, submitForm, } = useFormik({ validationSchema, @@ -244,13 +246,13 @@ function PaymentMadeForm({ // Handle cancel button click. const handleCancelClick = useCallback(() => { - history.push('/payment-mades'); + history.goBack(); }, [history]); // Handle clear all lines button click. - const handleClearAllLines = () => { + const handleClearAllLines = useCallback(() => { setClearLinesAlert(true); - }; + },[setClearLinesAlert]); const handleCancelClearLines = useCallback(() => { setClearLinesAlert(false); @@ -284,6 +286,7 @@ function PaymentMadeForm({ : {}), }); setClearFormAlert(false); + resetForm(); }; // Payable full amount. const payableFullAmount = useMemo(() => sumBy(values.entries, 'due_amount'), [ @@ -314,7 +317,6 @@ function PaymentMadeForm({ [setSubmitPayload], ); - return (
} confirmButtonText={Are you sure you want to clear this transaction?
+
+