mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20: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 EstimateFormMailDeliverDialogContent = React.lazy(
|
||||
() => import('./EstimateFormMailDeliverDialogContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Estimate mail dialog.
|
||||
*/
|
||||
function EstimateFormMailDeliverDialog({
|
||||
dialogName,
|
||||
payload: { estimateId = null },
|
||||
isOpen,
|
||||
}) {
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
title={'Estimate Mail'}
|
||||
isOpen={isOpen}
|
||||
canEscapeJeyClose={false}
|
||||
isCloseButtonShown={false}
|
||||
autoFocus={true}
|
||||
style={{ width: 600 }}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<EstimateFormMailDeliverDialogContent
|
||||
dialogName={dialogName}
|
||||
estimateId={estimateId}
|
||||
/>
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogRedux())(EstimateFormMailDeliverDialog);
|
||||
@@ -0,0 +1,40 @@
|
||||
// @ts-nocheck
|
||||
import * as R from 'ramda';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import EstimateMailDialogContent from '../../EstimateMailDialog/EstimateMailDialogContent';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
|
||||
interface EstimateFormDeliverDialogContent {
|
||||
estimateId: number;
|
||||
}
|
||||
|
||||
function EstimateFormDeliverDialogContentRoot({
|
||||
estimateId,
|
||||
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}: EstimateFormDeliverDialogContent) {
|
||||
const history = useHistory();
|
||||
|
||||
const handleSubmit = () => {
|
||||
closeDialog(DialogsName.EstimateFormMailDeliver);
|
||||
history.push('/estimates');
|
||||
};
|
||||
const handleCancel = () => {
|
||||
closeDialog(DialogsName.EstimateFormMailDeliver);
|
||||
history.push('/estimates');
|
||||
};
|
||||
|
||||
return (
|
||||
<EstimateMailDialogContent
|
||||
estimateId={estimateId}
|
||||
onFormSubmit={handleSubmit}
|
||||
onCancelClick={handleCancel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default R.compose(withDialogActions)(
|
||||
EstimateFormDeliverDialogContentRoot,
|
||||
);
|
||||
@@ -29,7 +29,7 @@ export default function EstimateFloatingActions() {
|
||||
|
||||
// Handle submit & deliver button click.
|
||||
const handleSubmitDeliverBtnClick = (event) => {
|
||||
setSubmitPayload({ redirect: true, deliver: true });
|
||||
setSubmitPayload({ redirect: false, deliverViaMail: true });
|
||||
submitForm();
|
||||
};
|
||||
|
||||
|
||||
@@ -36,11 +36,16 @@ import {
|
||||
handleErrors,
|
||||
resetFormState,
|
||||
} from './utils';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
|
||||
/**
|
||||
* Estimate form.
|
||||
*/
|
||||
function EstimateForm({
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
// #withSettings
|
||||
estimateNextNumber,
|
||||
estimateNumberPrefix,
|
||||
@@ -108,7 +113,7 @@ function EstimateForm({
|
||||
delivered: submitPayload.deliver,
|
||||
};
|
||||
// Handle the request success.
|
||||
const onSuccess = (response) => {
|
||||
const onSuccess = (res) => {
|
||||
AppToaster.show({
|
||||
message: intl.get(
|
||||
isNewMode
|
||||
@@ -126,6 +131,11 @@ function EstimateForm({
|
||||
if (submitPayload.resetForm) {
|
||||
resetFormState({ resetForm, initialValues, values });
|
||||
}
|
||||
if (submitPayload.deliverViaMail) {
|
||||
openDialog(DialogsName.EstimateFormMailDeliver, {
|
||||
estimateId: res.data.id,
|
||||
});
|
||||
}
|
||||
};
|
||||
// Handle the request error.
|
||||
const onError = ({
|
||||
@@ -180,6 +190,7 @@ function EstimateForm({
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withDialogActions,
|
||||
withSettings(({ estimatesSettings }) => ({
|
||||
estimateNextNumber: estimatesSettings?.nextNumber,
|
||||
estimateNumberPrefix: estimatesSettings?.numberPrefix,
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
import React from 'react';
|
||||
import { useFormikContext } from 'formik';
|
||||
import EstimateNumberDialog from '@/containers/Dialogs/EstimateNumberDialog';
|
||||
import EstimateFormMailDeliverDialog from './Dialogs/EstimateFormMailDeliverDialog';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
|
||||
/**
|
||||
* Estimate form dialogs.
|
||||
@@ -25,6 +27,9 @@ export default function EstimateFormDialogs() {
|
||||
dialogName={'estimate-number-form'}
|
||||
onConfirm={handleEstimateNumberFormConfirm}
|
||||
/>
|
||||
<EstimateFormMailDeliverDialog
|
||||
dialogName={DialogsName.EstimateFormMailDeliver}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user