mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat(webapp): showing up mail popup once saving invoice, receipt and estimate
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import { Dialog, DialogSuspense } from '@/components';
|
||||
import withDialogRedux from '@/components/DialogReduxConnect';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
const ReceiptFormMailDeliverDialogContent = React.lazy(
|
||||
() => import('./ReceiptFormMailDeliverDialogContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Receipt mail dialog.
|
||||
*/
|
||||
function ReceiptFormMailDeliverDialog({
|
||||
dialogName,
|
||||
payload: { receiptId = null },
|
||||
isOpen,
|
||||
}) {
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
title={'Receipt Mail'}
|
||||
isOpen={isOpen}
|
||||
canEscapeJeyClose={false}
|
||||
isCloseButtonShown={false}
|
||||
autoFocus={true}
|
||||
style={{ width: 600 }}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<ReceiptFormMailDeliverDialogContent
|
||||
dialogName={dialogName}
|
||||
receiptId={receiptId}
|
||||
/>
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogRedux())(ReceiptFormMailDeliverDialog);
|
||||
@@ -0,0 +1,40 @@
|
||||
// @ts-nocheck
|
||||
import * as R from 'ramda';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import ReceiptMailDialogContent from '../../ReceiptMailDialog/ReceiptMailDialogContent';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
|
||||
interface ReceiptFormDeliverDialogContent {
|
||||
receiptId: number;
|
||||
}
|
||||
|
||||
function ReceiptFormDeliverDialogContentRoot({
|
||||
receiptId,
|
||||
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}: ReceiptFormDeliverDialogContent) {
|
||||
const history = useHistory();
|
||||
|
||||
const handleSubmit = () => {
|
||||
history.push('/receipts');
|
||||
closeDialog(DialogsName.ReceiptFormMailDeliver);
|
||||
};
|
||||
const handleCancel = () => {
|
||||
history.push('/receipts');
|
||||
closeDialog(DialogsName.ReceiptFormMailDeliver);
|
||||
};
|
||||
|
||||
return (
|
||||
<ReceiptMailDialogContent
|
||||
receiptId={receiptId}
|
||||
onFormSubmit={handleSubmit}
|
||||
onCancelClick={handleCancel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default R.compose(withDialogActions)(
|
||||
ReceiptFormDeliverDialogContentRoot,
|
||||
);
|
||||
@@ -34,12 +34,20 @@ import {
|
||||
transformFormValuesToRequest,
|
||||
resetFormState,
|
||||
} from './utils';
|
||||
import { ReceiptSyncAutoExRateToForm, ReceiptSyncIncrementSettingsToForm } from './components';
|
||||
import {
|
||||
ReceiptSyncAutoExRateToForm,
|
||||
ReceiptSyncIncrementSettingsToForm,
|
||||
} from './components';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
|
||||
/**
|
||||
* Receipt form.
|
||||
*/
|
||||
function ReceiptForm({
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
// #withSettings
|
||||
receiptNextNumber,
|
||||
receiptNumberPrefix,
|
||||
@@ -84,10 +92,7 @@ function ReceiptForm({
|
||||
}),
|
||||
};
|
||||
// Handle the form submit.
|
||||
const handleFormSubmit = (
|
||||
values,
|
||||
{ setErrors, setSubmitting, resetForm },
|
||||
) => {
|
||||
const handleFormSubmit = (values, { setErrors, setSubmitting }) => {
|
||||
const entries = values.entries.filter(
|
||||
(item) => item.item_id && item.quantity,
|
||||
);
|
||||
@@ -124,6 +129,11 @@ function ReceiptForm({
|
||||
if (submitPayload.resetForm) {
|
||||
resetFormState();
|
||||
}
|
||||
if (submitPayload.deliverMail) {
|
||||
openDialog(DialogsName.ReceiptFormMailDeliver, {
|
||||
receiptId: response.data.id,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Handle the request error.
|
||||
@@ -179,6 +189,7 @@ function ReceiptForm({
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withDialogActions,
|
||||
withDashboardActions,
|
||||
withSettings(({ receiptSettings }) => ({
|
||||
receiptNextNumber: receiptSettings?.nextNumber,
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
import React from 'react';
|
||||
import { useFormikContext } from 'formik';
|
||||
import ReceiptNumberDialog from '@/containers/Dialogs/ReceiptNumberDialog';
|
||||
import ReceiptFormMailDeliverDialog from './Dialogs/ReceiptFormMailDeliverDialog';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
|
||||
/**
|
||||
* Receipt form dialogs.
|
||||
@@ -27,6 +29,9 @@ export default function ReceiptFormDialogs() {
|
||||
dialogName={'receipt-number-form'}
|
||||
onConfirm={handleReceiptNumberFormConfirm}
|
||||
/>
|
||||
<ReceiptFormMailDeliverDialog
|
||||
dialogName={DialogsName.ReceiptFormMailDeliver}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ export default function ReceiptFormFloatingActions() {
|
||||
|
||||
// Handle submit & close button click.
|
||||
const handleSubmitCloseBtnClick = (event) => {
|
||||
setSubmitPayload({ redirect: true, status: true });
|
||||
setSubmitPayload({ redirect: false, deliverMail: true, status: true });
|
||||
submitForm();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user