mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
feat(webapp): add ability to redirect to list to mail dialogs
This commit is contained in:
@@ -13,7 +13,12 @@ const PaymentMailDialogContent = React.lazy(
|
||||
*/
|
||||
function PaymentMailDialog({
|
||||
dialogName,
|
||||
payload: { paymentReceiveId = null },
|
||||
payload: {
|
||||
paymentReceiveId = null,
|
||||
|
||||
// Redirects to the payments list on mail submitting.
|
||||
redirectToPaymentsList = false,
|
||||
},
|
||||
isOpen,
|
||||
}) {
|
||||
return (
|
||||
@@ -29,6 +34,7 @@ function PaymentMailDialog({
|
||||
<PaymentMailDialogContent
|
||||
dialogName={dialogName}
|
||||
paymentReceiveId={paymentReceiveId}
|
||||
redirectToPaymentsList={redirectToPaymentsList}
|
||||
/>
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
|
||||
@@ -13,6 +13,7 @@ const PaymentMailDialogBootContext =
|
||||
|
||||
interface PaymentMailDialogBootProps {
|
||||
paymentReceiveId: number;
|
||||
redirectToPaymentsList: boolean;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
@@ -29,7 +30,8 @@ function PaymentMailDialogBoot({
|
||||
const provider = {
|
||||
mailOptions,
|
||||
isMailOptionsLoading,
|
||||
paymentReceiveId
|
||||
paymentReceiveId,
|
||||
redirectToPaymentsList
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -4,13 +4,18 @@ import { PaymentMailDialogForm } from './PaymentMailDialogForm';
|
||||
interface PaymentMailDialogContentProps {
|
||||
dialogName: string;
|
||||
paymentReceiveId: number;
|
||||
redirectToPaymentsList: boolean;
|
||||
}
|
||||
export default function PaymentMailDialogContent({
|
||||
dialogName,
|
||||
paymentReceiveId,
|
||||
redirectToPaymentsList,
|
||||
}: PaymentMailDialogContentProps) {
|
||||
return (
|
||||
<PaymentMailDialogBoot paymentReceiveId={paymentReceiveId}>
|
||||
<PaymentMailDialogBoot
|
||||
paymentReceiveId={paymentReceiveId}
|
||||
redirectToPaymentsList={redirectToPaymentsList}
|
||||
>
|
||||
<PaymentMailDialogForm />
|
||||
</PaymentMailDialogBoot>
|
||||
);
|
||||
|
||||
@@ -3,7 +3,6 @@ import { Formik, FormikBag } from 'formik';
|
||||
import * as R from 'ramda';
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
import { usePaymentMailDialogBoot } from './PaymentMailDialogBoot';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
import { useSendPaymentReceiveMail } from '@/hooks/query';
|
||||
import { PaymentMailDialogFormContent } from './PaymentMailDialogFormContent';
|
||||
@@ -14,6 +13,8 @@ import {
|
||||
transformMailFormToInitialValues,
|
||||
} from '@/containers/SendMailNotification/utils';
|
||||
import { AppToaster } from '@/components';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
|
||||
const initialFormValues = {
|
||||
...initialMailNotificationValues,
|
||||
@@ -28,9 +29,12 @@ export function PaymentMailDialogFormRoot({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
const { mailOptions, paymentReceiveId } = usePaymentMailDialogBoot();
|
||||
const { mailOptions, paymentReceiveId, redirectToPaymentsList } =
|
||||
usePaymentMailDialogBoot();
|
||||
const { mutateAsync: sendPaymentMail } = useSendPaymentReceiveMail();
|
||||
|
||||
const history = useHistory();
|
||||
|
||||
const initialValues = transformMailFormToInitialValues(
|
||||
mailOptions,
|
||||
initialFormValues,
|
||||
@@ -51,6 +55,11 @@ export function PaymentMailDialogFormRoot({
|
||||
});
|
||||
setSubmitting(false);
|
||||
closeDialog(DialogsName.PaymentMail);
|
||||
|
||||
// Redirects to payments list if the option is enabled.
|
||||
if (redirectToPaymentsList) {
|
||||
history.push('/payment-receives');
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
AppToaster.show({
|
||||
|
||||
Reference in New Issue
Block a user