mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
feat(webapp): showing up mail popup once saving invoice, receipt and estimate
This commit is contained in:
@@ -4,8 +4,8 @@ import { Dialog, DialogSuspense } from '@/components';
|
||||
import withDialogRedux from '@/components/DialogReduxConnect';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
const InvoiceMailDialogContent = React.lazy(
|
||||
() => import('./InvoiceMailDialogContent'),
|
||||
const InvoiceMailDialogBody = React.lazy(
|
||||
() => import('./InvoiceMailDialogBody'),
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -13,12 +13,7 @@ const InvoiceMailDialogContent = React.lazy(
|
||||
*/
|
||||
function InvoiceMailDialog({
|
||||
dialogName,
|
||||
payload: {
|
||||
invoiceId = null,
|
||||
|
||||
// Redirects to the invoices list.
|
||||
redirectToInvoicesList = false,
|
||||
},
|
||||
payload: { invoiceId = null },
|
||||
isOpen,
|
||||
}) {
|
||||
return (
|
||||
@@ -26,16 +21,13 @@ function InvoiceMailDialog({
|
||||
name={dialogName}
|
||||
title={'Invoice Mail'}
|
||||
isOpen={isOpen}
|
||||
canEscapeJeyClose={true}
|
||||
canEscapeJeyClose={false}
|
||||
isCloseButtonShown={false}
|
||||
autoFocus={true}
|
||||
style={{ width: 600 }}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<InvoiceMailDialogContent
|
||||
dialogName={dialogName}
|
||||
invoiceId={invoiceId}
|
||||
redirectToInvoicesList={redirectToInvoicesList}
|
||||
/>
|
||||
<InvoiceMailDialogBody invoiceId={invoiceId} />
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// @ts-nocheck
|
||||
import * as R from 'ramda';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import InvoiceMailDialogContent, {
|
||||
InvoiceMailDialogContentProps,
|
||||
} from './InvoiceMailDialogContent';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
|
||||
export interface InvoiceMailDialogBodyProps
|
||||
extends InvoiceMailDialogContentProps {}
|
||||
|
||||
function InvoiceMailDialogBodyRoot({
|
||||
invoiceId,
|
||||
onCancelClick,
|
||||
onFormSubmit,
|
||||
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}: InvoiceMailDialogBodyProps) {
|
||||
const handleCancelClick = () => {
|
||||
closeDialog(DialogsName.InvoiceMail);
|
||||
};
|
||||
const handleSubmitClick = () => {
|
||||
closeDialog(DialogsName.InvoiceMail);
|
||||
};
|
||||
|
||||
return (
|
||||
<InvoiceMailDialogContent
|
||||
invoiceId={invoiceId}
|
||||
onCancelClick={handleCancelClick}
|
||||
onFormSubmit={handleSubmitClick}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default R.compose(withDialogActions)(InvoiceMailDialogBodyRoot);
|
||||
@@ -1,24 +1,22 @@
|
||||
import { InvoiceMailDialogBoot } from './InvoiceMailDialogBoot';
|
||||
import { InvoiceMailDialogForm } from './InvoiceMailDialogForm';
|
||||
|
||||
interface InvoiceMailDialogContentProps {
|
||||
dialogName: string;
|
||||
export interface InvoiceMailDialogContentProps {
|
||||
invoiceId: number;
|
||||
|
||||
// Redirect to invoices list after submitting the message.
|
||||
redirectToInvoicesList?: boolean;
|
||||
onFormSubmit?: () => void;
|
||||
onCancelClick?: () => void;
|
||||
}
|
||||
export default function InvoiceMailDialogContent({
|
||||
dialogName,
|
||||
invoiceId,
|
||||
redirectToInvoicesList,
|
||||
onFormSubmit,
|
||||
onCancelClick,
|
||||
}: InvoiceMailDialogContentProps) {
|
||||
return (
|
||||
<InvoiceMailDialogBoot
|
||||
invoiceId={invoiceId}
|
||||
redirectToInvoicesList={redirectToInvoicesList}
|
||||
>
|
||||
<InvoiceMailDialogForm />
|
||||
<InvoiceMailDialogBoot invoiceId={invoiceId}>
|
||||
<InvoiceMailDialogForm
|
||||
onFormSubmit={onFormSubmit}
|
||||
onCancelClick={onCancelClick}
|
||||
/>
|
||||
</InvoiceMailDialogBoot>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
// @ts-nocheck
|
||||
import { Formik } from 'formik';
|
||||
import * as R from 'ramda';
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
import { useInvoiceMailDialogBoot } from './InvoiceMailDialogBoot';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
import { AppToaster } from '@/components';
|
||||
import { useSendSaleInvoiceMail } from '@/hooks/query';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { InvoiceMailDialogFormContent } from './InvoiceMailDialogFormContent';
|
||||
import { InvoiceMailFormSchema } from './InvoiceMailDialogForm.schema';
|
||||
import {
|
||||
@@ -15,7 +12,6 @@ import {
|
||||
transformMailFormToRequest,
|
||||
transformMailFormToInitialValues,
|
||||
} from '@/containers/SendMailNotification/utils';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
const initialFormValues = {
|
||||
...initialMailNotificationValues,
|
||||
@@ -26,13 +22,8 @@ interface InvoiceMailFormValues extends MailNotificationFormValues {
|
||||
attachInvoice: boolean;
|
||||
}
|
||||
|
||||
function InvoiceMailDialogFormRoot({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
const history = useHistory();
|
||||
const { mailOptions, saleInvoiceId, redirectToInvoicesList } =
|
||||
useInvoiceMailDialogBoot();
|
||||
export function InvoiceMailDialogForm({ onFormSubmit, onCancelClick }) {
|
||||
const { mailOptions, saleInvoiceId } = useInvoiceMailDialogBoot();
|
||||
const { mutateAsync: sendInvoiceMail } = useSendSaleInvoiceMail();
|
||||
|
||||
const initialValues = transformMailFormToInitialValues(
|
||||
@@ -50,13 +41,8 @@ function InvoiceMailDialogFormRoot({
|
||||
message: 'The mail notification has been sent successfully.',
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
closeDialog(DialogsName.InvoiceMail);
|
||||
setSubmitting(false);
|
||||
|
||||
// Redirect to the dashboard if the option was enabled.
|
||||
if (redirectToInvoicesList) {
|
||||
history.push('/invoices');
|
||||
}
|
||||
onFormSubmit && onFormSubmit(values);
|
||||
})
|
||||
.catch(() => {
|
||||
AppToaster.show({
|
||||
@@ -68,7 +54,7 @@ function InvoiceMailDialogFormRoot({
|
||||
};
|
||||
// Handle the close button click.
|
||||
const handleClose = () => {
|
||||
closeDialog(DialogsName.InvoiceMail);
|
||||
onCancelClick && onCancelClick();
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -81,7 +67,3 @@ function InvoiceMailDialogFormRoot({
|
||||
</Formik>
|
||||
);
|
||||
}
|
||||
|
||||
export const InvoiceMailDialogForm = R.compose(withDialogActions)(
|
||||
InvoiceMailDialogFormRoot,
|
||||
);
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export * from './InvoiceMailDialog';
|
||||
export * from './InvoiceMailDialog';
|
||||
export * from './InvoiceMailDialogContent';
|
||||
Reference in New Issue
Block a user