mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
feat(webapp): add ability to redirect to list to mail dialogs
This commit is contained in:
@@ -13,7 +13,12 @@ const EstimateMailDialogContent = React.lazy(
|
|||||||
*/
|
*/
|
||||||
function EstimateMailDialog({
|
function EstimateMailDialog({
|
||||||
dialogName,
|
dialogName,
|
||||||
payload: { estimateId = null },
|
payload: {
|
||||||
|
estimateId = null,
|
||||||
|
|
||||||
|
// Redirect to the estimates list after mail submitting.
|
||||||
|
redirectToEstimatesList = false,
|
||||||
|
},
|
||||||
isOpen,
|
isOpen,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
@@ -29,6 +34,7 @@ function EstimateMailDialog({
|
|||||||
<EstimateMailDialogContent
|
<EstimateMailDialogContent
|
||||||
dialogName={dialogName}
|
dialogName={dialogName}
|
||||||
estimateId={estimateId}
|
estimateId={estimateId}
|
||||||
|
redirectToEstimatesList={redirectToEstimatesList}
|
||||||
/>
|
/>
|
||||||
</DialogSuspense>
|
</DialogSuspense>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ import { DialogContent } from '@/components';
|
|||||||
interface EstimateMailDialogBootValues {
|
interface EstimateMailDialogBootValues {
|
||||||
estimateId: number;
|
estimateId: number;
|
||||||
mailOptions: any;
|
mailOptions: any;
|
||||||
|
redirectToEstimatesList: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EstimateMailDialagBoot = createContext<EstimateMailDialogBootValues>();
|
const EstimateMailDialagBoot = createContext<EstimateMailDialogBootValues>();
|
||||||
|
|
||||||
interface EstimateMailDialogBootProps {
|
interface EstimateMailDialogBootProps {
|
||||||
estimateId: number;
|
estimateId: number;
|
||||||
|
redirectToEstimatesList?: boolean;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,6 +22,7 @@ interface EstimateMailDialogBootProps {
|
|||||||
*/
|
*/
|
||||||
function EstimateMailDialogBoot({
|
function EstimateMailDialogBoot({
|
||||||
estimateId,
|
estimateId,
|
||||||
|
redirectToEstimatesList,
|
||||||
...props
|
...props
|
||||||
}: EstimateMailDialogBootProps) {
|
}: EstimateMailDialogBootProps) {
|
||||||
const { data: mailOptions, isLoading: isMailOptionsLoading } =
|
const { data: mailOptions, isLoading: isMailOptionsLoading } =
|
||||||
@@ -29,6 +32,7 @@ function EstimateMailDialogBoot({
|
|||||||
saleEstimateId: estimateId,
|
saleEstimateId: estimateId,
|
||||||
mailOptions,
|
mailOptions,
|
||||||
isMailOptionsLoading,
|
isMailOptionsLoading,
|
||||||
|
redirectToEstimatesList,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -4,14 +4,19 @@ import { EstimateMailDialogForm } from './EstimateMailDialogForm';
|
|||||||
interface EstimateMailDialogContentProps {
|
interface EstimateMailDialogContentProps {
|
||||||
dialogName: string;
|
dialogName: string;
|
||||||
estimateId: number;
|
estimateId: number;
|
||||||
|
redirectToEstimatesList?: boolean;
|
||||||
}
|
}
|
||||||
export default function EstimateMailDialogContent({
|
export default function EstimateMailDialogContent({
|
||||||
dialogName,
|
dialogName,
|
||||||
estimateId,
|
estimateId,
|
||||||
|
redirectToEstimatesList,
|
||||||
}: EstimateMailDialogContentProps) {
|
}: EstimateMailDialogContentProps) {
|
||||||
return (
|
return (
|
||||||
<EstimateMailDialogBoot estimateId={estimateId}>
|
<EstimateMailDialogBoot
|
||||||
<EstimateMailDialogForm />
|
estimateId={estimateId}
|
||||||
|
redirectToEstimatesList={redirectToEstimatesList}
|
||||||
|
>
|
||||||
|
<EstimateMailDialogForm />
|
||||||
</EstimateMailDialogBoot>
|
</EstimateMailDialogBoot>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { Formik } from 'formik';
|
import { Formik } from 'formik';
|
||||||
import * as R from 'ramda';
|
import * as R from 'ramda';
|
||||||
|
import { Intent } from '@blueprintjs/core';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
import { useEstimateMailDialogBoot } from './EstimateMailDialogBoot';
|
import { useEstimateMailDialogBoot } from './EstimateMailDialogBoot';
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
@@ -12,7 +14,6 @@ import {
|
|||||||
transformMailFormToInitialValues,
|
transformMailFormToInitialValues,
|
||||||
transformMailFormToRequest,
|
transformMailFormToRequest,
|
||||||
} from '@/containers/SendMailNotification/utils';
|
} from '@/containers/SendMailNotification/utils';
|
||||||
import { Intent } from '@blueprintjs/core';
|
|
||||||
import { AppToaster } from '@/components';
|
import { AppToaster } from '@/components';
|
||||||
|
|
||||||
const initialFormValues = {
|
const initialFormValues = {
|
||||||
@@ -29,7 +30,10 @@ function EstimateMailDialogFormRoot({
|
|||||||
closeDialog,
|
closeDialog,
|
||||||
}) {
|
}) {
|
||||||
const { mutateAsync: sendEstimateMail } = useSendSaleEstimateMail();
|
const { mutateAsync: sendEstimateMail } = useSendSaleEstimateMail();
|
||||||
const { mailOptions, saleEstimateId } = useEstimateMailDialogBoot();
|
const { mailOptions, saleEstimateId, redirectToEstimatesList } =
|
||||||
|
useEstimateMailDialogBoot();
|
||||||
|
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
const initialValues = transformMailFormToInitialValues(
|
const initialValues = transformMailFormToInitialValues(
|
||||||
mailOptions,
|
mailOptions,
|
||||||
@@ -48,8 +52,12 @@ function EstimateMailDialogFormRoot({
|
|||||||
});
|
});
|
||||||
closeDialog(DialogsName.EstimateMail);
|
closeDialog(DialogsName.EstimateMail);
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
|
|
||||||
|
if (redirectToEstimatesList) {
|
||||||
|
history.push('/estimates');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(() => {
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
closeDialog(DialogsName.EstimateMail);
|
closeDialog(DialogsName.EstimateMail);
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
|
|||||||
@@ -13,7 +13,12 @@ const InvoiceMailDialogContent = React.lazy(
|
|||||||
*/
|
*/
|
||||||
function InvoiceMailDialog({
|
function InvoiceMailDialog({
|
||||||
dialogName,
|
dialogName,
|
||||||
payload: { invoiceId = null },
|
payload: {
|
||||||
|
invoiceId = null,
|
||||||
|
|
||||||
|
// Redirects to the invoices list.
|
||||||
|
redirectToInvoicesList = false,
|
||||||
|
},
|
||||||
isOpen,
|
isOpen,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
@@ -29,6 +34,7 @@ function InvoiceMailDialog({
|
|||||||
<InvoiceMailDialogContent
|
<InvoiceMailDialogContent
|
||||||
dialogName={dialogName}
|
dialogName={dialogName}
|
||||||
invoiceId={invoiceId}
|
invoiceId={invoiceId}
|
||||||
|
redirectToInvoicesList={redirectToInvoicesList}
|
||||||
/>
|
/>
|
||||||
</DialogSuspense>
|
</DialogSuspense>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ import { DialogContent } from '@/components';
|
|||||||
interface InvoiceMailDialogBootValues {
|
interface InvoiceMailDialogBootValues {
|
||||||
invoiceId: number;
|
invoiceId: number;
|
||||||
mailOptions: any;
|
mailOptions: any;
|
||||||
|
redirectToInvoicesList: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const InvoiceMailDialagBoot = createContext<InvoiceMailDialogBootValues>();
|
const InvoiceMailDialagBoot = createContext<InvoiceMailDialogBootValues>();
|
||||||
|
|
||||||
interface InvoiceMailDialogBootProps {
|
interface InvoiceMailDialogBootProps {
|
||||||
invoiceId: number;
|
invoiceId: number;
|
||||||
|
redirectToInvoicesList?: boolean;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,6 +22,7 @@ interface InvoiceMailDialogBootProps {
|
|||||||
*/
|
*/
|
||||||
function InvoiceMailDialogBoot({
|
function InvoiceMailDialogBoot({
|
||||||
invoiceId,
|
invoiceId,
|
||||||
|
redirectToInvoicesList,
|
||||||
...props
|
...props
|
||||||
}: InvoiceMailDialogBootProps) {
|
}: InvoiceMailDialogBootProps) {
|
||||||
const { data: mailOptions, isLoading: isMailOptionsLoading } =
|
const { data: mailOptions, isLoading: isMailOptionsLoading } =
|
||||||
@@ -29,6 +32,7 @@ function InvoiceMailDialogBoot({
|
|||||||
saleInvoiceId: invoiceId,
|
saleInvoiceId: invoiceId,
|
||||||
mailOptions,
|
mailOptions,
|
||||||
isMailOptionsLoading,
|
isMailOptionsLoading,
|
||||||
|
redirectToInvoicesList,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -4,13 +4,20 @@ import { InvoiceMailDialogForm } from './InvoiceMailDialogForm';
|
|||||||
interface InvoiceMailDialogContentProps {
|
interface InvoiceMailDialogContentProps {
|
||||||
dialogName: string;
|
dialogName: string;
|
||||||
invoiceId: number;
|
invoiceId: number;
|
||||||
|
|
||||||
|
// Redirect to invoices list after submitting the message.
|
||||||
|
redirectToInvoicesList?: boolean;
|
||||||
}
|
}
|
||||||
export default function InvoiceMailDialogContent({
|
export default function InvoiceMailDialogContent({
|
||||||
dialogName,
|
dialogName,
|
||||||
invoiceId,
|
invoiceId,
|
||||||
|
redirectToInvoicesList,
|
||||||
}: InvoiceMailDialogContentProps) {
|
}: InvoiceMailDialogContentProps) {
|
||||||
return (
|
return (
|
||||||
<InvoiceMailDialogBoot invoiceId={invoiceId}>
|
<InvoiceMailDialogBoot
|
||||||
|
invoiceId={invoiceId}
|
||||||
|
redirectToInvoicesList={redirectToInvoicesList}
|
||||||
|
>
|
||||||
<InvoiceMailDialogForm />
|
<InvoiceMailDialogForm />
|
||||||
</InvoiceMailDialogBoot>
|
</InvoiceMailDialogBoot>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
transformMailFormToRequest,
|
transformMailFormToRequest,
|
||||||
transformMailFormToInitialValues,
|
transformMailFormToInitialValues,
|
||||||
} from '@/containers/SendMailNotification/utils';
|
} from '@/containers/SendMailNotification/utils';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
const initialFormValues = {
|
const initialFormValues = {
|
||||||
...initialMailNotificationValues,
|
...initialMailNotificationValues,
|
||||||
@@ -29,7 +30,9 @@ function InvoiceMailDialogFormRoot({
|
|||||||
// #withDialogActions
|
// #withDialogActions
|
||||||
closeDialog,
|
closeDialog,
|
||||||
}) {
|
}) {
|
||||||
const { mailOptions, saleInvoiceId } = useInvoiceMailDialogBoot();
|
const history = useHistory();
|
||||||
|
const { mailOptions, saleInvoiceId, redirectToInvoicesList } =
|
||||||
|
useInvoiceMailDialogBoot();
|
||||||
const { mutateAsync: sendInvoiceMail } = useSendSaleInvoiceMail();
|
const { mutateAsync: sendInvoiceMail } = useSendSaleInvoiceMail();
|
||||||
|
|
||||||
const initialValues = transformMailFormToInitialValues(
|
const initialValues = transformMailFormToInitialValues(
|
||||||
@@ -49,6 +52,11 @@ function InvoiceMailDialogFormRoot({
|
|||||||
});
|
});
|
||||||
closeDialog(DialogsName.InvoiceMail);
|
closeDialog(DialogsName.InvoiceMail);
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
|
|
||||||
|
// Redirect to the dashboard if the option was enabled.
|
||||||
|
if (redirectToInvoicesList) {
|
||||||
|
history.push('/invoices');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
|
|||||||
@@ -13,7 +13,12 @@ const PaymentMailDialogContent = React.lazy(
|
|||||||
*/
|
*/
|
||||||
function PaymentMailDialog({
|
function PaymentMailDialog({
|
||||||
dialogName,
|
dialogName,
|
||||||
payload: { paymentReceiveId = null },
|
payload: {
|
||||||
|
paymentReceiveId = null,
|
||||||
|
|
||||||
|
// Redirects to the payments list on mail submitting.
|
||||||
|
redirectToPaymentsList = false,
|
||||||
|
},
|
||||||
isOpen,
|
isOpen,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
@@ -29,6 +34,7 @@ function PaymentMailDialog({
|
|||||||
<PaymentMailDialogContent
|
<PaymentMailDialogContent
|
||||||
dialogName={dialogName}
|
dialogName={dialogName}
|
||||||
paymentReceiveId={paymentReceiveId}
|
paymentReceiveId={paymentReceiveId}
|
||||||
|
redirectToPaymentsList={redirectToPaymentsList}
|
||||||
/>
|
/>
|
||||||
</DialogSuspense>
|
</DialogSuspense>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ const PaymentMailDialogBootContext =
|
|||||||
|
|
||||||
interface PaymentMailDialogBootProps {
|
interface PaymentMailDialogBootProps {
|
||||||
paymentReceiveId: number;
|
paymentReceiveId: number;
|
||||||
|
redirectToPaymentsList: boolean;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +30,8 @@ function PaymentMailDialogBoot({
|
|||||||
const provider = {
|
const provider = {
|
||||||
mailOptions,
|
mailOptions,
|
||||||
isMailOptionsLoading,
|
isMailOptionsLoading,
|
||||||
paymentReceiveId
|
paymentReceiveId,
|
||||||
|
redirectToPaymentsList
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -4,13 +4,18 @@ import { PaymentMailDialogForm } from './PaymentMailDialogForm';
|
|||||||
interface PaymentMailDialogContentProps {
|
interface PaymentMailDialogContentProps {
|
||||||
dialogName: string;
|
dialogName: string;
|
||||||
paymentReceiveId: number;
|
paymentReceiveId: number;
|
||||||
|
redirectToPaymentsList: boolean;
|
||||||
}
|
}
|
||||||
export default function PaymentMailDialogContent({
|
export default function PaymentMailDialogContent({
|
||||||
dialogName,
|
dialogName,
|
||||||
paymentReceiveId,
|
paymentReceiveId,
|
||||||
|
redirectToPaymentsList,
|
||||||
}: PaymentMailDialogContentProps) {
|
}: PaymentMailDialogContentProps) {
|
||||||
return (
|
return (
|
||||||
<PaymentMailDialogBoot paymentReceiveId={paymentReceiveId}>
|
<PaymentMailDialogBoot
|
||||||
|
paymentReceiveId={paymentReceiveId}
|
||||||
|
redirectToPaymentsList={redirectToPaymentsList}
|
||||||
|
>
|
||||||
<PaymentMailDialogForm />
|
<PaymentMailDialogForm />
|
||||||
</PaymentMailDialogBoot>
|
</PaymentMailDialogBoot>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { Formik, FormikBag } from 'formik';
|
|||||||
import * as R from 'ramda';
|
import * as R from 'ramda';
|
||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
import { usePaymentMailDialogBoot } from './PaymentMailDialogBoot';
|
import { usePaymentMailDialogBoot } from './PaymentMailDialogBoot';
|
||||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
import { useSendPaymentReceiveMail } from '@/hooks/query';
|
import { useSendPaymentReceiveMail } from '@/hooks/query';
|
||||||
import { PaymentMailDialogFormContent } from './PaymentMailDialogFormContent';
|
import { PaymentMailDialogFormContent } from './PaymentMailDialogFormContent';
|
||||||
@@ -14,6 +13,8 @@ import {
|
|||||||
transformMailFormToInitialValues,
|
transformMailFormToInitialValues,
|
||||||
} from '@/containers/SendMailNotification/utils';
|
} from '@/containers/SendMailNotification/utils';
|
||||||
import { AppToaster } from '@/components';
|
import { AppToaster } from '@/components';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
const initialFormValues = {
|
const initialFormValues = {
|
||||||
...initialMailNotificationValues,
|
...initialMailNotificationValues,
|
||||||
@@ -28,9 +29,12 @@ export function PaymentMailDialogFormRoot({
|
|||||||
// #withDialogActions
|
// #withDialogActions
|
||||||
closeDialog,
|
closeDialog,
|
||||||
}) {
|
}) {
|
||||||
const { mailOptions, paymentReceiveId } = usePaymentMailDialogBoot();
|
const { mailOptions, paymentReceiveId, redirectToPaymentsList } =
|
||||||
|
usePaymentMailDialogBoot();
|
||||||
const { mutateAsync: sendPaymentMail } = useSendPaymentReceiveMail();
|
const { mutateAsync: sendPaymentMail } = useSendPaymentReceiveMail();
|
||||||
|
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
const initialValues = transformMailFormToInitialValues(
|
const initialValues = transformMailFormToInitialValues(
|
||||||
mailOptions,
|
mailOptions,
|
||||||
initialFormValues,
|
initialFormValues,
|
||||||
@@ -51,6 +55,11 @@ export function PaymentMailDialogFormRoot({
|
|||||||
});
|
});
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
closeDialog(DialogsName.PaymentMail);
|
closeDialog(DialogsName.PaymentMail);
|
||||||
|
|
||||||
|
// Redirects to payments list if the option is enabled.
|
||||||
|
if (redirectToPaymentsList) {
|
||||||
|
history.push('/payment-receives');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
|
|||||||
@@ -13,7 +13,12 @@ const ReceiptMailDialogContent = React.lazy(
|
|||||||
*/
|
*/
|
||||||
function ReceiptMailDialog({
|
function ReceiptMailDialog({
|
||||||
dialogName,
|
dialogName,
|
||||||
payload: { receiptId = null },
|
payload: {
|
||||||
|
receiptId = null,
|
||||||
|
|
||||||
|
// Redirects to receipts list after mail submitting.
|
||||||
|
redirectToReceiptsList = false,
|
||||||
|
},
|
||||||
isOpen,
|
isOpen,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
@@ -29,6 +34,7 @@ function ReceiptMailDialog({
|
|||||||
<ReceiptMailDialogContent
|
<ReceiptMailDialogContent
|
||||||
dialogName={dialogName}
|
dialogName={dialogName}
|
||||||
receiptId={receiptId}
|
receiptId={receiptId}
|
||||||
|
redirectToReceiptsList={redirectToReceiptsList}
|
||||||
/>
|
/>
|
||||||
</DialogSuspense>
|
</DialogSuspense>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { DialogContent } from '@/components';
|
|||||||
interface ReceiptMailDialogBootValues {
|
interface ReceiptMailDialogBootValues {
|
||||||
receiptId: number;
|
receiptId: number;
|
||||||
mailOptions: any;
|
mailOptions: any;
|
||||||
|
redirectToReceiptsList: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReceiptMailDialogBootContext =
|
const ReceiptMailDialogBootContext =
|
||||||
@@ -14,6 +15,7 @@ const ReceiptMailDialogBootContext =
|
|||||||
interface ReceiptMailDialogBootProps {
|
interface ReceiptMailDialogBootProps {
|
||||||
receiptId: number;
|
receiptId: number;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
redirectToReceiptsList?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +23,7 @@ interface ReceiptMailDialogBootProps {
|
|||||||
*/
|
*/
|
||||||
function ReceiptMailDialogBoot({
|
function ReceiptMailDialogBoot({
|
||||||
receiptId,
|
receiptId,
|
||||||
|
redirectToReceiptsList = false,
|
||||||
...props
|
...props
|
||||||
}: ReceiptMailDialogBootProps) {
|
}: ReceiptMailDialogBootProps) {
|
||||||
const { data: mailOptions, isLoading: isMailOptionsLoading } =
|
const { data: mailOptions, isLoading: isMailOptionsLoading } =
|
||||||
@@ -30,6 +33,7 @@ function ReceiptMailDialogBoot({
|
|||||||
saleReceiptId: receiptId,
|
saleReceiptId: receiptId,
|
||||||
mailOptions,
|
mailOptions,
|
||||||
isMailOptionsLoading,
|
isMailOptionsLoading,
|
||||||
|
redirectToReceiptsList,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -3,15 +3,20 @@ import { ReceiptMailDialogBoot } from './ReceiptMailDialogBoot';
|
|||||||
import { ReceiptMailDialogForm } from './ReceiptMailDialogForm';
|
import { ReceiptMailDialogForm } from './ReceiptMailDialogForm';
|
||||||
|
|
||||||
interface ReceiptMailDialogContentProps {
|
interface ReceiptMailDialogContentProps {
|
||||||
dialogName: string
|
dialogName: string;
|
||||||
receiptId: number;
|
receiptId: number;
|
||||||
|
redirectToReceiptsList?: boolean;
|
||||||
}
|
}
|
||||||
export default function ReceiptMailDialogContent({
|
export default function ReceiptMailDialogContent({
|
||||||
dialogName,
|
dialogName,
|
||||||
receiptId,
|
receiptId,
|
||||||
|
redirectToReceiptsList = false,
|
||||||
}: ReceiptMailDialogContentProps) {
|
}: ReceiptMailDialogContentProps) {
|
||||||
return (
|
return (
|
||||||
<ReceiptMailDialogBoot receiptId={receiptId}>
|
<ReceiptMailDialogBoot
|
||||||
|
receiptId={receiptId}
|
||||||
|
redirectToReceiptsList={redirectToReceiptsList}
|
||||||
|
>
|
||||||
<ReceiptMailDialogForm />
|
<ReceiptMailDialogForm />
|
||||||
</ReceiptMailDialogBoot>
|
</ReceiptMailDialogBoot>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { Formik, FormikBag } from 'formik';
|
import { Formik, FormikBag } from 'formik';
|
||||||
import * as R from 'ramda';
|
import * as R from 'ramda';
|
||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
import { useReceiptMailDialogBoot } from './ReceiptMailDialogBoot';
|
import { useReceiptMailDialogBoot } from './ReceiptMailDialogBoot';
|
||||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
import { DialogsName } from '@/constants/dialogs';
|
import { DialogsName } from '@/constants/dialogs';
|
||||||
@@ -24,9 +25,12 @@ interface ReceiptMailFormValues extends MailNotificationFormValues {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ReceiptMailDialogFormRoot({ closeDialog }) {
|
function ReceiptMailDialogFormRoot({ closeDialog }) {
|
||||||
const { mailOptions, saleReceiptId } = useReceiptMailDialogBoot();
|
const { mailOptions, saleReceiptId, redirectToReceiptsList } =
|
||||||
|
useReceiptMailDialogBoot();
|
||||||
const { mutateAsync: sendReceiptMail } = useSendSaleReceiptMail();
|
const { mutateAsync: sendReceiptMail } = useSendSaleReceiptMail();
|
||||||
|
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
// Transformes mail options to initial form values.
|
// Transformes mail options to initial form values.
|
||||||
const initialValues = transformMailFormToInitialValues(
|
const initialValues = transformMailFormToInitialValues(
|
||||||
mailOptions,
|
mailOptions,
|
||||||
@@ -48,6 +52,10 @@ function ReceiptMailDialogFormRoot({ closeDialog }) {
|
|||||||
});
|
});
|
||||||
closeDialog(DialogsName.ReceiptMail);
|
closeDialog(DialogsName.ReceiptMail);
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
|
|
||||||
|
if (redirectToReceiptsList) {
|
||||||
|
history.push('/receipts');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
|
|||||||
Reference in New Issue
Block a user