);
}
diff --git a/client/src/containers/Accounting/MakeJournalEntriesForm.js b/client/src/containers/Accounting/MakeJournalEntriesForm.js
index 0eded5f18..988bceb94 100644
--- a/client/src/containers/Accounting/MakeJournalEntriesForm.js
+++ b/client/src/containers/Accounting/MakeJournalEntriesForm.js
@@ -11,6 +11,7 @@ import moment from 'moment';
import { Intent } from '@blueprintjs/core';
import { useIntl } from 'react-intl';
import { pick, setWith } from 'lodash';
+import { useHistory } from 'react-router-dom';
import MakeJournalEntriesHeader from './MakeJournalEntriesHeader';
import MakeJournalEntriesFooter from './MakeJournalEntriesFooter';
@@ -77,6 +78,9 @@ function MakeJournalEntriesForm({
onCancelForm,
}) {
const { formatMessage } = useIntl();
+ const history = useHistory();
+ const [submitPayload, setSubmitPayload] = useState({});
+
const {
setFiles,
saveMedia,
@@ -163,8 +167,6 @@ function MakeJournalEntriesForm({
[onFormSubmit],
);
- const [payload, setPayload] = useState({});
-
const defaultEntry = useMemo(
() => ({
index: 0,
@@ -183,6 +185,7 @@ function MakeJournalEntriesForm({
date: moment(new Date()).format('YYYY-MM-DD'),
description: '',
reference: '',
+ status:'',
currency_code: '',
entries: [...repeatValue(defaultEntry, 4)],
}),
@@ -289,6 +292,8 @@ function MakeJournalEntriesForm({
setFieldValue,
handleSubmit,
getFieldProps,
+ submitForm,
+ resetForm,
touched,
isSubmitting,
} = useFormik({
@@ -327,7 +332,7 @@ function MakeJournalEntriesForm({
setSubmitting(false);
return;
}
- const form = { ...values, status: payload.publish, entries };
+ const form = { ...values, status: submitPayload.publish, entries };
const saveJournal = (mediaIds) =>
new Promise((resolve, reject) => {
@@ -344,7 +349,7 @@ function MakeJournalEntriesForm({
intent: Intent.SUCCESS,
});
setSubmitting(false);
- saveInvokeSubmit({ action: 'update', ...payload });
+ saveInvokeSubmit({ action: 'update', ...submitPayload });
clearSavedMediaIds([]);
resetForm();
resolve(response);
@@ -364,9 +369,11 @@ function MakeJournalEntriesForm({
intent: Intent.SUCCESS,
});
setSubmitting(false);
- saveInvokeSubmit({ action: 'new', ...payload });
+ saveInvokeSubmit({ action: 'new', ...submitPayload });
clearSavedMediaIds();
- resetForm();
+ if (submitPayload.resetForm) {
+ resetForm();
+ }
resolve(response);
})
.catch((errors) => {
@@ -407,20 +414,15 @@ function MakeJournalEntriesForm({
]);
const handleSubmitClick = useCallback(
- (payload) => {
- setPayload(payload);
- // formik.resetForm();
- handleSubmit();
+ (event, payload) => {
+ setSubmitPayload({ ...payload });
},
- [setPayload, handleSubmit],
+ [setSubmitPayload],
);
- const handleCancelClick = useCallback(
- (payload) => {
- onCancelForm && onCancelForm(payload);
- },
- [onCancelForm],
- );
+ const handleCancelClick = useCallback(() => {
+ history.goBack();
+ }, [history]);
const handleDeleteFile = useCallback(
(_deletedFiles) => {
@@ -453,11 +455,12 @@ function MakeJournalEntriesForm({
const handleJournalNumberChanged = useCallback(
(journalNumber) => {
changePageSubtitle(
- defaultToTransform(journalNumber, `No. ${journalNumber}`, '')
+ defaultToTransform(journalNumber, `No. ${journalNumber}`, ''),
);
},
[changePageSubtitle],
);
+
return (
diff --git a/client/src/containers/Expenses/ExpenseFloatingActions.js b/client/src/containers/Expenses/ExpenseFloatingActions.js
index eda5ff0a9..84fc445ea 100644
--- a/client/src/containers/Expenses/ExpenseFloatingActions.js
+++ b/client/src/containers/Expenses/ExpenseFloatingActions.js
@@ -14,7 +14,7 @@ import { FormattedMessage as T } from 'react-intl';
import { CLASSES } from 'common/classes';
import classNames from 'classnames';
import { saveInvoke } from 'utils';
-import { Icon } from 'components';
+import { Icon, If } from 'components';
/**
* Expense form floating actions.
@@ -25,11 +25,18 @@ export default function ExpenseFloatingFooter({
onCancelClick,
onDraftClick,
onClearClick,
- onSubmitAndNewClick,
onSubmitForm,
onResetForm,
expense,
+ expensePublished,
}) {
+ const handleSubmitPublishBtnClick = (event) => {
+ saveInvoke(onSubmitClick, event, {
+ redirect: true,
+ publish: true,
+ });
+ };
+
const handleSubmitPublishAndNewBtnClick = (event) => {
onSubmitForm();
saveInvoke(onSubmitClick, event, {
@@ -47,6 +54,13 @@ export default function ExpenseFloatingFooter({
});
};
+ const handleSubmitDraftBtnClick = (event) => {
+ saveInvoke(onSubmitClick, event, {
+ redirect: true,
+ publish: false,
+ });
+ };
+
const handleSubmitDraftAndNewBtnClick = (event) => {
onSubmitForm();
saveInvoke(onSubmitClick, event, {
@@ -60,106 +74,129 @@ export default function ExpenseFloatingFooter({
onSubmitForm();
saveInvoke(onSubmitClick, event, {
redirect: false,
- publish: true,
+ publish: false,
});
};
+ const handleCancelBtnClick = (event) => {
+ saveInvoke(onCancelClick, event);
+ };
+
+ const handleClearBtnClick = (event) => {
+ // saveInvoke(onClearClick, event);
+ onResetForm();
+ };
+
return (
-
- {/* ----------- Save And Publish ----------- */}
-
{/* ----------- Save As Draft ----------- */}
-
{
- saveInvoke(onSubmitClick, event, {
- redirect: true,
- publish: false,
- });
- }}
- text={}
- />
-
- }
- onClick={handleSubmitDraftAndNewBtnClick}
- />
- }
- onClick={handleSubmitDraftContinueEditingBtnClick}
- />
-
- }
- minimal={true}
- interactionKind={PopoverInteractionKind.CLICK}
- position={Position.BOTTOM_LEFT}
- >
- } />
-
- {/* ----------- Clear ----------- */}
- {
- onResetForm();
- saveInvoke(onClearClick, event);
- }}
- text={expense && expense.id ? : }
- />
- {/* ----------- Cancel ----------- */}
- {
- saveInvoke(onCancelClick, event);
- }}
- text={}
- />
-
+
+ }
+ />
+
+ }
+ onClick={handleSubmitDraftAndNewBtnClick}
+ />
+ }
+ onClick={handleSubmitDraftContinueEditingBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+
+ {/* ----------- Save and New ----------- */}
+
+
+ }
+ />
+
+ }
+ onClick={handleSubmitPublishAndNewBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+
+ {/* ----------- Clear & Reset----------- */}
+ : }
+ />
+ {/* ----------- Cancel ----------- */}
+ }
+ />
);
}
diff --git a/client/src/containers/Expenses/ExpenseForm.js b/client/src/containers/Expenses/ExpenseForm.js
index 943df21a9..189e31d96 100644
--- a/client/src/containers/Expenses/ExpenseForm.js
+++ b/client/src/containers/Expenses/ExpenseForm.js
@@ -304,7 +304,6 @@ function ExpenseForm({
history.goBack();
}, [history]);
-
const handleDeleteFile = useCallback(
(_deletedFiles) => {
_deletedFiles.forEach((deletedFile) => {
@@ -332,7 +331,7 @@ function ExpenseForm({
]),
);
};
-
+
return (
diff --git a/client/src/containers/Purchases/Bill/BillFloatingActions.js b/client/src/containers/Purchases/Bill/BillFloatingActions.js
index c71848ea5..bdadae9e8 100644
--- a/client/src/containers/Purchases/Bill/BillFloatingActions.js
+++ b/client/src/containers/Purchases/Bill/BillFloatingActions.js
@@ -1,8 +1,24 @@
import React from 'react';
-import { Intent, Button } from '@blueprintjs/core';
+import {
+ Intent,
+ Button,
+ ButtonGroup,
+ Popover,
+ PopoverInteractionKind,
+ Position,
+ Menu,
+ MenuItem,
+} from '@blueprintjs/core';
+import { useFormikContext } from 'formik';
import { FormattedMessage as T } from 'react-intl';
+import { CLASSES } from 'common/classes';
+import classNames from 'classnames';
import { saveInvoke } from 'utils';
+import { If, Icon } from 'components';
+/**
+ * Bill floating actions bar.
+ */
export default function BillFloatingActions({
isSubmitting,
onSubmitClick,
@@ -10,53 +26,176 @@ export default function BillFloatingActions({
onCancelClick,
onClearClick,
billId,
+ billPublished,
}) {
+ const { resetForm, submitForm } = useFormikContext();
+
+ const handleSubmitPublishBtnClick = (event) => {
+ saveInvoke(onSubmitClick, event, {
+ redirect: true,
+ });
+ };
+
+ const handleSubmitPublishAndNewBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: true,
+ resetForm: true,
+ });
+ };
+
+ const handleSubmitPublishContinueEditingBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: true,
+ });
+ };
+
+ const handleSubmitDraftBtnClick = (event) => {
+ saveInvoke(onSubmitClick, event, {
+ redirect: true,
+ publish: false,
+ });
+ };
+
+ const handleSubmitDraftAndNewBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: false,
+ resetForm: true,
+ });
+ };
+
+ const handleSubmitDraftContinueEditingBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: true,
+ });
+ };
+
+ const handleCancelBtnClick = (event) => {
+ saveInvoke(onCancelClick, event);
+ };
+
+ const handleClearBtnClick = (event) => {
+ // saveInvoke(onClearClick, event);
+ resetForm();
+ };
+
return (
-
-
{
- saveInvoke(onSubmitClick, event);
- }}
- >
- {billId ? : }
-
-
-
{
- saveInvoke(onSubmitAndNewClick, event);
- }}
- >
-
-
-
+
+ {/* ----------- Save And Publish ----------- */}
+
+
+ }
+ />
+
+ }
+ onClick={handleSubmitPublishAndNewBtnClick}
+ />
+ }
+ onClick={handleSubmitPublishContinueEditingBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+
+ {/* ----------- Save and New ----------- */}
+
+
+ }
+ />
+
+ }
+ onClick={handleSubmitPublishAndNewBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+ {/* ----------- Save As Draft ----------- */}
+
+ }
+ />
+
+ }
+ onClick={handleSubmitDraftAndNewBtnClick}
+ />
+ }
+ onClick={handleSubmitDraftContinueEditingBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+
+ {/* ----------- Clear & Reset----------- */}
{
- saveInvoke(onClearClick, event);
- }}
- >
-
-
-
+ onClick={handleClearBtnClick}
+ text={billId ?
:
}
+ />
+ {/* ----------- Cancel ----------- */}
{
- saveInvoke(onCancelClick, event);
- }}
- >
-
-
+ onClick={handleCancelBtnClick}
+ text={
}
+ />
);
}
diff --git a/client/src/containers/Purchases/Bill/BillForm.js b/client/src/containers/Purchases/Bill/BillForm.js
index e9488d242..01b9cc136 100644
--- a/client/src/containers/Purchases/Bill/BillForm.js
+++ b/client/src/containers/Purchases/Bill/BillForm.js
@@ -22,7 +22,12 @@ import withBillDetail from './withBillDetail';
import { AppToaster } from 'components';
import { ERROR } from 'common/errors';
-import { compose, repeatValue, defaultToTransform, orderingLinesIndexes } from 'utils';
+import {
+ compose,
+ repeatValue,
+ defaultToTransform,
+ orderingLinesIndexes,
+} from 'utils';
const MIN_LINES_NUMBER = 5;
@@ -154,11 +159,13 @@ function BillForm({
});
setSubmitting(false);
- resetForm();
changePageSubtitle('');
if (submitPayload.redirect) {
- history.go('/bills');
+ history.push('/bills');
+ }
+ if (submitPayload.resetForm) {
+ resetForm();
}
};
// Handle the request error.
@@ -189,9 +196,12 @@ function BillForm({
[changePageSubtitle],
);
- const handleSubmitClick = useCallback(() => {
- setSubmitPayload({ redirect: true });
- }, [setSubmitPayload]);
+ const handleSubmitClick = useCallback(
+ (event, payload) => {
+ setSubmitPayload({ ...payload });
+ },
+ [setSubmitPayload],
+ );
const handleCancelClick = useCallback(() => {
history.goBack();
@@ -218,6 +228,7 @@ function BillForm({
diff --git a/client/src/containers/Purchases/PaymentMades/PaymentMadeFloatingActions.js b/client/src/containers/Purchases/PaymentMades/PaymentMadeFloatingActions.js
index 8befdee8e..7b4363e14 100644
--- a/client/src/containers/Purchases/PaymentMades/PaymentMadeFloatingActions.js
+++ b/client/src/containers/Purchases/PaymentMades/PaymentMadeFloatingActions.js
@@ -1,9 +1,19 @@
import React from 'react';
-import { Intent, Button } from '@blueprintjs/core';
+import {
+ Intent,
+ Button,
+ ButtonGroup,
+ Popover,
+ PopoverInteractionKind,
+ Position,
+ Menu,
+ MenuItem,
+} from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl';
import classNames from 'classnames';
-
import { CLASSES } from 'common/classes';
+import { saveInvoke } from 'utils';
+import { Icon } from 'components';
/**
* Payment made floating actions bar.
@@ -13,56 +23,85 @@ export default function PaymentMadeFloatingActions({
onSubmitClick,
onCancelClick,
onClearBtnClick,
+ onSubmitForm,
+ paymentMadeId,
}) {
+ const handleSubmitBtnClick = (event) => {
+ saveInvoke(onSubmitClick, event, {
+ redirect: true,
+ });
+ };
+
const handleClearBtnClick = (event) => {
onClearBtnClick && onClearBtnClick(event);
};
- const handleSubmitClick = (event) => {
- onSubmitClick && onSubmitClick(event, { redirect: true });
- };
-
- const handleCancelClick = (event) => {
+ const handleCancelBtnClick = (event) => {
onCancelClick && onCancelClick(event);
+ saveInvoke(onCancelClick, event);
};
+ const handleSubmitAndNewClick = (event) => {
+ onSubmitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ });
+ };
+
+ const handleSubmitContinueEditingBtnClick = (event) => {
+ onSubmitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: true,
+ });
+ };
return (
-
-
-
-
-
-
-
-
+ {/* ----------- Save and New ----------- */}
+
+ : }
+ />
+
+ }
+ onClick={handleSubmitAndNewClick}
+ />
+ }
+ onClick={handleSubmitContinueEditingBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+ {/* ----------- Clear & Reset----------- */}
-
-
-
+ text={paymentMadeId ?
:
}
+ />
+ {/* ----------- Cancel ----------- */}
-
-
+ onClick={handleCancelBtnClick}
+ text={
}
+ />
);
}
diff --git a/client/src/containers/Purchases/PaymentMades/PaymentMadeForm.js b/client/src/containers/Purchases/PaymentMades/PaymentMadeForm.js
index b12a59cbd..073e79033 100644
--- a/client/src/containers/Purchases/PaymentMades/PaymentMadeForm.js
+++ b/client/src/containers/Purchases/PaymentMades/PaymentMadeForm.js
@@ -81,6 +81,7 @@ function PaymentMadeForm({
const [clearLinesAlert, setClearLinesAlert] = useState(false);
const [clearFormAlert, setClearFormAlert] = useState(false);
const [fullAmount, setFullAmount] = useState(null);
+ const [submitPayload, setSubmitPayload] = useState({});
const [localPaymentEntries, setLocalPaymentEntries] = useState(
paymentMadeEntries,
@@ -96,7 +97,7 @@ function PaymentMadeForm({
const validationSchema = isNewMode
? CreatePaymentMadeFormSchema
: EditPaymentMadeFormSchema;
-
+
// Form initial values.
const initialValues = useMemo(
() => ({
@@ -155,8 +156,13 @@ function PaymentMadeForm({
intent: Intent.SUCCESS,
});
setSubmitting(false);
- resetForm();
+ // resetForm();
changePageSubtitle('');
+
+ if (submitPayload.redirect) {
+ history.push('/payment-mades');
+ }
+
};
const onError = (errors) => {
@@ -187,6 +193,7 @@ function PaymentMadeForm({
values,
handleSubmit,
isSubmitting,
+ submitForm,
} = useFormik({
validationSchema,
initialValues,
@@ -300,6 +307,14 @@ function PaymentMadeForm({
[values.entries],
);
+ const handleSubmitClick = useCallback(
+ (event, payload) => {
+ setSubmitPayload({ ...payload });
+ },
+ [setSubmitPayload],
+ );
+
+
return (
{/*
{
+ const handleSubmitPublishBtnClick = (event) => {
saveInvoke(onSubmitClick, event, {
redirect: true,
+ publish: true
+ });
+ };
+
+ const handleSubmitPublishAndNewBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: true,
+ resetForm: true,
+ });
+ };
+
+ const handleSubmitPublishContinueEditingBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: true,
+ });
+ };
+
+ const handleSubmitDraftBtnClick = (event) => {
+ saveInvoke(onSubmitClick, event, {
+ redirect: true,
+ publish: false,
+ });
+ };
+
+ const handleSubmitDraftAndNewBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: false,
+ resetForm: true,
+ });
+ };
+
+ const handleSubmitDraftContinueEditingBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: false,
});
};
@@ -43,56 +86,117 @@ export default function EstimateFloatingActions({
resetForm();
};
- const handleSubmitAndNewClick = (event) => {
- submitForm();
- saveInvoke(onSubmitClick, event, {
- redirect: false,
- });
- };
-
return (
-
- {/* ----------- Save and New ----------- */}
- : }
- />
-
- }
- onClick={handleSubmitAndNewClick}
- />
-
- }
- minimal={true}
- interactionKind={PopoverInteractionKind.CLICK}
- position={Position.BOTTOM_LEFT}
- >
+ {/* ----------- Save And Publish ----------- */}
+
+
}
+ type="submit"
+ onClick={handleSubmitPublishBtnClick}
+ text={}
/>
-
- {/* ----------- Clear & Reset----------- */}
- : }
- />
- {/* ----------- Cancel ----------- */}
- }
- />
-
+
+ }
+ onClick={handleSubmitPublishAndNewBtnClick}
+ />
+ }
+ onClick={handleSubmitPublishContinueEditingBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+ {/* ----------- Save As Draft ----------- */}
+
+ }
+ />
+
+ }
+ onClick={handleSubmitDraftAndNewBtnClick}
+ />
+ }
+ onClick={handleSubmitDraftContinueEditingBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+
+ {/* ----------- Save and New ----------- */}
+
+
+ }
+ />
+
+ }
+ onClick={handleSubmitPublishAndNewBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+
+
+ {/* ----------- Clear & Reset----------- */}
+
:
}
+ />
+ {/* ----------- Cancel ----------- */}
+
}
+ />
);
}
diff --git a/client/src/containers/Sales/Estimate/EstimateForm.js b/client/src/containers/Sales/Estimate/EstimateForm.js
index 21eb167cf..32e427339 100644
--- a/client/src/containers/Sales/Estimate/EstimateForm.js
+++ b/client/src/containers/Sales/Estimate/EstimateForm.js
@@ -103,9 +103,9 @@ const EstimateForm = ({
: estimateNextNumber;
useEffect(() => {
- const transNumber = !isNewMode ? estimate.estimate_number : estimateNumber;
+ const transNumber = !isNewMode ? estimate.estimate_number : estimateNumber;
- if (isNewMode) {
+ if (!isNewMode) {
changePageTitle(formatMessage({ id: 'edit_estimate' }));
} else {
changePageTitle(formatMessage({ id: 'new_estimate' }));
@@ -199,11 +199,13 @@ const EstimateForm = ({
intent: Intent.SUCCESS,
});
setSubmitting(false);
- resetForm();
if (submitPayload.redirect) {
history.push('/estimates');
}
+ if (submitPayload.resetForm) {
+ resetForm();
+ }
};
const onError = (errors) => {
@@ -263,8 +265,8 @@ const EstimateForm = ({
estimateId={estimateId}
onSubmitClick={handleSubmitClick}
onCancelClick={handleCancelClick}
+ estimatePublished={true}
/>
-
)}
diff --git a/client/src/containers/Sales/Invoice/InvoiceFloatingActions.js b/client/src/containers/Sales/Invoice/InvoiceFloatingActions.js
index 0004df237..39b586a40 100644
--- a/client/src/containers/Sales/Invoice/InvoiceFloatingActions.js
+++ b/client/src/containers/Sales/Invoice/InvoiceFloatingActions.js
@@ -14,8 +14,7 @@ import { FormattedMessage as T } from 'react-intl';
import { CLASSES } from 'common/classes';
import classNames from 'classnames';
import { saveInvoke } from 'utils';
-import { Icon } from 'components';
-
+import { If, Icon } from 'components';
/**
* Invoice floating actions bar.
@@ -26,151 +25,178 @@ export default function InvoiceFloatingActions({
onCancelClick,
onClearClick,
invoice,
+ invoicePublished,
}) {
const { resetForm, submitForm } = useFormikContext();
- const handleSubmitPublishAndNewBtnClick = useCallback(
- (event) => {
- submitForm();
- saveInvoke(onSubmitClick, event, {
- redirect: false,
- publish: true,
- resetForm: true,
- });
- },
- [submitForm],
- );
+ const handleSubmitPublishBtnClick = (event) => {
+ saveInvoke(onSubmitClick, event, {
+ redirect: true,
+ publish: true
+ });
+ };
- const handleSubmitPublishContinueEditingBtnClick = useCallback(
- (event) => {
- submitForm();
- saveInvoke(onSubmitClick, event, {
- redirect: false,
- publish: true,
- });
- },
- [submitForm],
- );
+ const handleSubmitPublishAndNewBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: true,
+ resetForm: true,
+ });
+ };
- const handleSubmitDraftAndNewBtnClick = useCallback(
- (event) => {
- submitForm();
- saveInvoke(onSubmitClick, event, {
- redirect: false,
- publish: false,
- resetForm: true,
- });
- },
- [submitForm],
- );
+ const handleSubmitPublishContinueEditingBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: true,
+ });
+ };
- const handleSubmitDraftContinueEditingBtnClick = useCallback(
- (event) => {
- submitForm();
- saveInvoke(onSubmitClick, event, {
- redirect: false,
- publish: true,
- });
- },
- [submitForm],
- );
+ const handleSubmitDraftBtnClick = (event) => {
+ saveInvoke(onSubmitClick, event, {
+ redirect: true,
+ publish: false,
+ });
+ };
+
+ const handleSubmitDraftAndNewBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: false,
+ resetForm: true,
+ });
+ };
+
+ const handleSubmitDraftContinueEditingBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: false,
+ });
+ };
+
+ const handleCancelBtnClick = (event) => {
+ saveInvoke(onCancelClick, event);
+ };
+
+ const handleClearBtnClick = (event) => {
+ // saveInvoke(onClearClick, event);
+ resetForm();
+ };
return (
-
- {/* ----------- Save And Publish ----------- */}
- {
- saveInvoke(onSubmitClick, event, {
- redirect: true,
- publish: true,
- });
- }}
- text={
- invoice && invoice.id ? (
-
- ) : (
-
- )
- }
- />
-
- }
- onClick={handleSubmitPublishAndNewBtnClick}
- />
- }
- onClick={handleSubmitPublishContinueEditingBtnClick}
- />
-
- }
- minimal={true}
- interactionKind={PopoverInteractionKind.CLICK}
- position={Position.BOTTOM_LEFT}
- >
+ {/* ----------- Save And Publish ----------- */}
+
+
}
+ type="submit"
+ onClick={handleSubmitPublishBtnClick}
+ text={}
/>
-
-
+
+ }
+ onClick={handleSubmitPublishAndNewBtnClick}
+ />
+ }
+ onClick={handleSubmitPublishContinueEditingBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
{/* ----------- Save As Draft ----------- */}
-
{
- saveInvoke(onSubmitClick, event, {
- redirect: true,
- publish: false,
- });
- }}
- text={}
- />
-
- }
- onClick={handleSubmitDraftAndNewBtnClick}
- />
- }
- onClick={handleSubmitDraftContinueEditingBtnClick}
- />
-
- }
- minimal={true}
- interactionKind={PopoverInteractionKind.CLICK}
- position={Position.BOTTOM_LEFT}
- >
- } />
-
- {/* ----------- Clear ----------- */}
- {
- resetForm();
- saveInvoke(onClearClick, event);
- }}
- text={invoice && invoice.id ? : }
- />
- {/* ----------- Cancel ----------- */}
- {
- saveInvoke(onCancelClick, event);
- }}
- text={}
- />
-
+
+ }
+ />
+
+ }
+ onClick={handleSubmitDraftAndNewBtnClick}
+ />
+ }
+ onClick={handleSubmitDraftContinueEditingBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+
+ {/* ----------- Save and New ----------- */}
+
+
+ }
+ />
+
+ }
+ onClick={handleSubmitPublishAndNewBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+
+
+ {/* ----------- Clear & Reset----------- */}
+ : }
+ />
+ {/* ----------- Cancel ----------- */}
+ }
+ />
);
}
diff --git a/client/src/containers/Sales/Invoice/InvoiceForm.js b/client/src/containers/Sales/Invoice/InvoiceForm.js
index fc20481b3..162213a4f 100644
--- a/client/src/containers/Sales/Invoice/InvoiceForm.js
+++ b/client/src/containers/Sales/Invoice/InvoiceForm.js
@@ -186,7 +186,6 @@ function InvoiceForm({
intent: Intent.SUCCESS,
});
setSubmitting(false);
- resetForm();
if (submitPayload.redirect) {
history.push('/invoices');
@@ -230,7 +229,7 @@ function InvoiceForm({
},
[changePageSubtitle],
);
-
+
return (
)}
diff --git a/client/src/containers/Sales/PaymentReceive/PaymentReceiveFloatingActions.js b/client/src/containers/Sales/PaymentReceive/PaymentReceiveFloatingActions.js
index 2f02013c4..318ea4a9e 100644
--- a/client/src/containers/Sales/PaymentReceive/PaymentReceiveFloatingActions.js
+++ b/client/src/containers/Sales/PaymentReceive/PaymentReceiveFloatingActions.js
@@ -46,19 +46,28 @@ export default function PaymentReceiveFormFloatingActions({
onSubmitForm();
saveInvoke(onSubmitClick, event, {
redirect: false,
+ resetForm: true,
+ });
+ };
+
+ const handleSubmitContinueEditingBtnClick = (event) => {
+ onSubmitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: true,
});
};
return (
+ {/* ----------- Save and New ----------- */}
- {/* ----------- Save and New ----------- */}
: }
+ text={paymentReceiveId ? : }
/>
}
onClick={handleSubmitAndNewClick}
/>
+ }
+ onClick={handleSubmitContinueEditingBtnClick}
+ />
}
minimal={true}
@@ -78,20 +91,20 @@ export default function PaymentReceiveFormFloatingActions({
rightIcon={}
/>
- {/* ----------- Clear & Reset----------- */}
- : }
- />
- {/* ----------- Cancel ----------- */}
- }
- />
+ {/* ----------- Clear & Reset----------- */}
+
:
}
+ />
+ {/* ----------- Cancel ----------- */}
+
}
+ />
);
}
diff --git a/client/src/containers/Sales/PaymentReceive/PaymentReceiveForm.js b/client/src/containers/Sales/PaymentReceive/PaymentReceiveForm.js
index 469e0f616..2dd56ece5 100644
--- a/client/src/containers/Sales/PaymentReceive/PaymentReceiveForm.js
+++ b/client/src/containers/Sales/PaymentReceive/PaymentReceiveForm.js
@@ -190,11 +190,13 @@ function PaymentReceiveForm({
intent: Intent.SUCCESS,
});
setSubmitting(false);
- resetForm();
if (submitPayload.redirect) {
history.push('/payment-receives');
}
+ if (submitPayload.resetForm) {
+ resetForm();
+ }
};
// Handle request response errors.
const onError = (errors) => {
@@ -366,7 +368,7 @@ function PaymentReceiveForm({
const handleCancelClick = useCallback(() => {
history.goBack();
}, [history]);
-
+
return (
diff --git a/client/src/containers/Sales/Receipt/ReceiptFormFloatingActions.js b/client/src/containers/Sales/Receipt/ReceiptFormFloatingActions.js
index c81044338..587ba2793 100644
--- a/client/src/containers/Sales/Receipt/ReceiptFormFloatingActions.js
+++ b/client/src/containers/Sales/Receipt/ReceiptFormFloatingActions.js
@@ -14,7 +14,7 @@ import { useFormikContext } from 'formik';
import classNames from 'classnames';
import { CLASSES } from 'common/classes';
import { saveInvoke } from 'utils';
-import { Icon } from 'components';
+import { If, Icon } from 'components';
/**
* Receipt floating actions bar.
@@ -22,21 +22,60 @@ import { Icon } from 'components';
export default function ReceiptFormFloatingActions({
isSubmitting,
receiptId,
+ receiptPublished,
onSubmitClick,
onCancelClick,
onClearClick,
}) {
const { resetForm, submitForm } = useFormikContext();
- const handleSubmitAndNewClick = useCallback(
- (event) => {
- submitForm();
- saveInvoke(onSubmitClick, event, {
- redirect: false,
- });
- },
- [submitForm],
- );
+ const handleSubmitPublishBtnClick = (event) => {
+ saveInvoke(onSubmitClick, event, {
+ redirect: true,
+ publish: true,
+ });
+ };
+
+ const handleSubmitPublishAndNewBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: true,
+ resetForm: true,
+ });
+ };
+
+ const handleSubmitPublishContinueEditingBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: true,
+ });
+ };
+
+ const handleSubmitDraftBtnClick = (event) => {
+ saveInvoke(onSubmitClick, event, {
+ redirect: true,
+ publish: false,
+ });
+ };
+
+ const handleSubmitDraftAndNewBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: false,
+ resetForm: true,
+ });
+ };
+
+ const handleSubmitDraftContinueEditingBtnClick = (event) => {
+ submitForm();
+ saveInvoke(onSubmitClick, event, {
+ redirect: false,
+ publish: false,
+ });
+ };
const handleCancelBtnClick = (event) => {
saveInvoke(onCancelClick, event);
@@ -49,51 +88,114 @@ export default function ReceiptFormFloatingActions({
return (
-
- {/* ----------- Save and New ----------- */}
- {
- saveInvoke(onSubmitClick, event, {
- redirect: true,
- });
- }}
- text={receiptId ? : }
- />
-
- }
- onClick={handleSubmitAndNewClick}
- />
-
- }
- minimal={true}
- interactionKind={PopoverInteractionKind.CLICK}
- position={Position.BOTTOM_LEFT}
- >
+ {/* ----------- Save And Publish ----------- */}
+
+
}
+ type="submit"
+ onClick={handleSubmitPublishBtnClick}
+ text={}
/>
-
- {/* ----------- Clear & Reset----------- */}
- : }
- />
- {/* ----------- Cancel ----------- */}
- }
- />
-
+
+ }
+ onClick={handleSubmitPublishAndNewBtnClick}
+ />
+ }
+ onClick={handleSubmitPublishContinueEditingBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+ {/* ----------- Save As Draft ----------- */}
+
+ }
+ />
+
+ }
+ onClick={handleSubmitDraftAndNewBtnClick}
+ />
+ }
+ onClick={handleSubmitDraftContinueEditingBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+
+ {/* ----------- Save and New ----------- */}
+
+
+ }
+ />
+
+ }
+ onClick={handleSubmitPublishAndNewBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+
+ {/* ----------- Clear & Reset----------- */}
+
:
}
+ />
+ {/* ----------- Cancel ----------- */}
+
}
+ />
);
}