fix: continue editing & clear in paymentmade.

This commit is contained in:
elforjani3
2021-01-09 19:40:00 +02:00
parent 73ccf1f86e
commit 43508dad38
2 changed files with 14 additions and 9 deletions

View File

@@ -45,6 +45,7 @@ export default function PaymentMadeFloatingActions({
onSubmitForm(); onSubmitForm();
saveInvoke(onSubmitClick, event, { saveInvoke(onSubmitClick, event, {
redirect: false, redirect: false,
resetForm: true,
}); });
}; };

View File

@@ -156,13 +156,14 @@ function PaymentMadeForm({
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
setSubmitting(false); setSubmitting(false);
// resetForm(); // changePageSubtitle('');
changePageSubtitle('');
if (submitPayload.redirect) { if (submitPayload.redirect) {
history.push('/payment-mades'); history.push('/payment-mades');
} }
if (submitPayload.resetForm) {
resetForm();
}
}; };
const onError = (errors) => { const onError = (errors) => {
@@ -193,6 +194,7 @@ function PaymentMadeForm({
values, values,
handleSubmit, handleSubmit,
isSubmitting, isSubmitting,
resetForm,
submitForm, submitForm,
} = useFormik({ } = useFormik({
validationSchema, validationSchema,
@@ -244,13 +246,13 @@ function PaymentMadeForm({
// Handle cancel button click. // Handle cancel button click.
const handleCancelClick = useCallback(() => { const handleCancelClick = useCallback(() => {
history.push('/payment-mades'); history.goBack();
}, [history]); }, [history]);
// Handle clear all lines button click. // Handle clear all lines button click.
const handleClearAllLines = () => { const handleClearAllLines = useCallback(() => {
setClearLinesAlert(true); setClearLinesAlert(true);
}; },[setClearLinesAlert]);
const handleCancelClearLines = useCallback(() => { const handleCancelClearLines = useCallback(() => {
setClearLinesAlert(false); setClearLinesAlert(false);
@@ -284,6 +286,7 @@ function PaymentMadeForm({
: {}), : {}),
}); });
setClearFormAlert(false); setClearFormAlert(false);
resetForm();
}; };
// Payable full amount. // Payable full amount.
const payableFullAmount = useMemo(() => sumBy(values.entries, 'due_amount'), [ const payableFullAmount = useMemo(() => sumBy(values.entries, 'due_amount'), [
@@ -314,7 +317,6 @@ function PaymentMadeForm({
[setSubmitPayload], [setSubmitPayload],
); );
return ( return (
<div <div
className={classNames( className={classNames(
@@ -382,12 +384,14 @@ function PaymentMadeForm({
<Alert <Alert
cancelButtonText={<T id={'cancel'} />} cancelButtonText={<T id={'cancel'} />}
confirmButtonText={<T id={'ok'} />} confirmButtonText={<T id={'ok'} />}
intent={Intent.DANGER} intent={Intent.WARNING}
isOpen={clearFormAlert} isOpen={clearFormAlert}
onCancel={handleCancelClearFormAlert} onCancel={handleCancelClearFormAlert}
onConfirm={handleConfirmCancelClearFormAlert} onConfirm={handleConfirmCancelClearFormAlert}
> >
<p>Are you sure you want to clear this transaction?</p> <p>
<T id={'are_you_sure_you_want_to_clear_this_transaction'} />
</p>
</Alert> </Alert>
<PaymentMadeFooter getFieldProps={getFieldProps} /> <PaymentMadeFooter getFieldProps={getFieldProps} />