mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
fix(webapp): remove duplicated form submitting
This commit is contained in:
@@ -27,7 +27,7 @@ export default function PaymentMadeFloatingActions() {
|
||||
const history = useHistory();
|
||||
|
||||
// Formik context.
|
||||
const { isSubmitting, resetForm } = useFormikContext();
|
||||
const { isSubmitting, resetForm, submitForm } = useFormikContext();
|
||||
|
||||
// Payment made form context.
|
||||
const { setSubmitPayload, paymentMadeId } = usePaymentMadeFormContext();
|
||||
@@ -50,12 +50,15 @@ export default function PaymentMadeFloatingActions() {
|
||||
// Handle submit & new button click.
|
||||
const handleSubmitAndNewClick = (event) => {
|
||||
setSubmitPayload({ redirect: false, resetForm: true });
|
||||
submitForm();
|
||||
};
|
||||
|
||||
// handle submit & continue editing button click.
|
||||
// Handle submit & continue editing button click.
|
||||
const handleSubmitContinueEditingBtnClick = (event) => {
|
||||
setSubmitPayload({ redirect: false, publish: true });
|
||||
submitForm()
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||
{/* ----------- Save and New ----------- */}
|
||||
|
||||
@@ -87,18 +87,19 @@ function PaymentMadeForm({
|
||||
message: intl.get('you_cannot_make_payment_with_zero_total_amount'),
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
setSubmitting(false);
|
||||
return;
|
||||
}
|
||||
// Transformes the form values to request body.
|
||||
const form = transformFormToRequest(values);
|
||||
|
||||
// Triggers once the save request success.
|
||||
const onSaved = (response) => {
|
||||
const onSaved = () => {
|
||||
AppToaster.show({
|
||||
message: intl.get(
|
||||
isNewMode
|
||||
? 'the_payment_made_has_been_edited_successfully'
|
||||
: 'the_payment_made_has_been_created_successfully',
|
||||
? 'the_payment_made_has_been_created_successfully'
|
||||
: 'the_payment_made_has_been_edited_successfully',
|
||||
),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
@@ -116,7 +117,6 @@ function PaymentMadeForm({
|
||||
if (errors) {
|
||||
transformErrors(errors, { setFieldError });
|
||||
}
|
||||
|
||||
setSubmitting(false);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user