mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
Merge branch 'develop' into big-116-open-up-the-link-component
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,
|
||||
);
|
||||
@@ -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}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ import { Dialog, DialogSuspense } from '@/components';
|
||||
import withDialogRedux from '@/components/DialogReduxConnect';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
const ReceiptMailDialogContent = React.lazy(
|
||||
() => import('./ReceiptMailDialogContent'),
|
||||
const ReceiptMailDialogBody = React.lazy(
|
||||
() => import('./ReceiptMailDialogBody'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Invoice mail dialog.
|
||||
* Receipt mail dialog.
|
||||
*/
|
||||
function ReceiptMailDialog({
|
||||
dialogName,
|
||||
@@ -26,10 +26,7 @@ function ReceiptMailDialog({
|
||||
style={{ width: 600 }}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<ReceiptMailDialogContent
|
||||
dialogName={dialogName}
|
||||
receiptId={receiptId}
|
||||
/>
|
||||
<ReceiptMailDialogBody receiptId={receiptId} />
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// @ts-nocheck
|
||||
import * as R from 'ramda';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import ReceiptMailDialogContent, {
|
||||
ReceiptMailDialogContentProps,
|
||||
} from './ReceiptMailDialogContent';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
|
||||
interface ReceiptMailDialogBodyProps extends ReceiptMailDialogContentProps {}
|
||||
|
||||
function ReceiptMailDialogBodyRoot({
|
||||
receiptId,
|
||||
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}: ReceiptMailDialogBodyProps) {
|
||||
const handleCancelClick = () => {
|
||||
closeDialog(DialogsName.ReceiptMail);
|
||||
};
|
||||
const handleSubmitClick = () => {
|
||||
closeDialog(DialogsName.ReceiptMail);
|
||||
};
|
||||
|
||||
return (
|
||||
<ReceiptMailDialogContent
|
||||
receiptId={receiptId}
|
||||
onFormSubmit={handleSubmitClick}
|
||||
onCancelClick={handleCancelClick}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default R.compose(withDialogActions)(ReceiptMailDialogBodyRoot);
|
||||
@@ -6,6 +6,7 @@ import { DialogContent } from '@/components';
|
||||
interface ReceiptMailDialogBootValues {
|
||||
receiptId: number;
|
||||
mailOptions: any;
|
||||
redirectToReceiptsList: boolean;
|
||||
}
|
||||
|
||||
const ReceiptMailDialogBootContext =
|
||||
@@ -14,6 +15,7 @@ const ReceiptMailDialogBootContext =
|
||||
interface ReceiptMailDialogBootProps {
|
||||
receiptId: number;
|
||||
children: React.ReactNode;
|
||||
redirectToReceiptsList?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -21,6 +23,7 @@ interface ReceiptMailDialogBootProps {
|
||||
*/
|
||||
function ReceiptMailDialogBoot({
|
||||
receiptId,
|
||||
redirectToReceiptsList = false,
|
||||
...props
|
||||
}: ReceiptMailDialogBootProps) {
|
||||
const { data: mailOptions, isLoading: isMailOptionsLoading } =
|
||||
@@ -30,6 +33,7 @@ function ReceiptMailDialogBoot({
|
||||
saleReceiptId: receiptId,
|
||||
mailOptions,
|
||||
isMailOptionsLoading,
|
||||
redirectToReceiptsList,
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -2,17 +2,22 @@ import React from 'react';
|
||||
import { ReceiptMailDialogBoot } from './ReceiptMailDialogBoot';
|
||||
import { ReceiptMailDialogForm } from './ReceiptMailDialogForm';
|
||||
|
||||
interface ReceiptMailDialogContentProps {
|
||||
dialogName: string
|
||||
export interface ReceiptMailDialogContentProps {
|
||||
receiptId: number;
|
||||
onFormSubmit?: () => void;
|
||||
onCancelClick?: () => void;
|
||||
}
|
||||
export default function ReceiptMailDialogContent({
|
||||
dialogName,
|
||||
receiptId,
|
||||
onFormSubmit,
|
||||
onCancelClick
|
||||
}: ReceiptMailDialogContentProps) {
|
||||
return (
|
||||
<ReceiptMailDialogBoot receiptId={receiptId}>
|
||||
<ReceiptMailDialogForm />
|
||||
<ReceiptMailDialogForm
|
||||
onFormSubmit={onFormSubmit}
|
||||
onCancelClick={onCancelClick}
|
||||
/>
|
||||
</ReceiptMailDialogBoot>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,16 @@ interface ReceiptMailFormValues extends MailNotificationFormValues {
|
||||
attachReceipt: boolean;
|
||||
}
|
||||
|
||||
function ReceiptMailDialogFormRoot({ closeDialog }) {
|
||||
interface ReceiptMailDialogFormProps {
|
||||
onFormSubmit?: () => void;
|
||||
onCancelClick?: () => void;
|
||||
}
|
||||
|
||||
export function ReceiptMailDialogForm({
|
||||
// #props
|
||||
onFormSubmit,
|
||||
onCancelClick,
|
||||
}: ReceiptMailDialogFormProps) {
|
||||
const { mailOptions, saleReceiptId } = useReceiptMailDialogBoot();
|
||||
const { mutateAsync: sendReceiptMail } = useSendSaleReceiptMail();
|
||||
|
||||
@@ -46,8 +55,8 @@ function ReceiptMailDialogFormRoot({ closeDialog }) {
|
||||
message: 'The mail notification has been sent successfully.',
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
closeDialog(DialogsName.ReceiptMail);
|
||||
setSubmitting(false);
|
||||
onFormSubmit && onFormSubmit(values);
|
||||
})
|
||||
.catch(() => {
|
||||
AppToaster.show({
|
||||
@@ -59,7 +68,7 @@ function ReceiptMailDialogFormRoot({ closeDialog }) {
|
||||
};
|
||||
// Handle the close button click.
|
||||
const handleClose = () => {
|
||||
closeDialog(DialogsName.ReceiptMail);
|
||||
onCancelClick && onCancelClick();
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -68,7 +77,3 @@ function ReceiptMailDialogFormRoot({ closeDialog }) {
|
||||
</Formik>
|
||||
);
|
||||
}
|
||||
|
||||
export const ReceiptMailDialogForm = R.compose(withDialogActions)(
|
||||
ReceiptMailDialogFormRoot,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user