diff --git a/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/InvoiceMailReceiptPreviewConnected..tsx b/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/InvoiceMailReceiptPreviewConnected..tsx deleted file mode 100644 index fe593a4ca..000000000 --- a/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/InvoiceMailReceiptPreviewConnected..tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { useMemo } from 'react'; -import { css } from '@emotion/css'; -import { Box, } from '@/components'; -import { InvoiceMailReceiptPreview } from '../InvoiceCustomize/InvoiceMailReceiptPreview'; -import { useInvoiceSendMailBoot } from './InvoiceSendMailContentBoot'; -import { InvoiceSendMailPreviewWithHeader } from './InvoiceSendMailHeaderPreview'; -import { useSendInvoiceMailMessage } from './_hooks'; - -export function InvoiceMailReceiptPreviewConneceted() { - const mailMessage = useSendInvoiceMailMessage(); - const { invoiceMailState } = useInvoiceSendMailBoot(); - - const items = useMemo( - () => - invoiceMailState?.entries?.map((entry: any) => ({ - quantity: entry.quantity, - total: entry.totalFormatted, - label: entry.name, - })), - [invoiceMailState?.entries], - ); - - return ( - - - - - - ); -} \ No newline at end of file diff --git a/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/InvoiceMailReceiptPreviewConnected.tsx b/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/InvoiceMailReceiptPreviewConnected.tsx new file mode 100644 index 000000000..ff6704ceb --- /dev/null +++ b/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/InvoiceMailReceiptPreviewConnected.tsx @@ -0,0 +1,64 @@ +import { useMemo, ComponentType } from 'react'; +import { css } from '@emotion/css'; +import { Box } from '@/components'; +import { + InvoiceMailReceiptPreview, + InvoiceMailReceiptPreviewProps, +} from '../InvoiceCustomize/InvoiceMailReceiptPreview'; +import { useInvoiceSendMailBoot } from './InvoiceSendMailContentBoot'; +import { InvoiceSendMailPreviewWithHeader } from './InvoiceSendMailHeaderPreview'; +import { useSendInvoiceMailMessage } from './_hooks'; + +export function InvoiceMailReceiptPreviewConnected() { + return ( + + + + + + ); +} + +/** + * Injects props from invoice mail state into the InvoiceMailReceiptPreview component. + */ +const withInvoiceMailReceiptPreviewProps = < + P extends InvoiceMailReceiptPreviewProps, +>( + WrappedComponent: ComponentType

, +) => { + return function WithInvoiceMailReceiptPreviewProps(props: P) { + const message = useSendInvoiceMailMessage(); + const { invoiceMailState } = useInvoiceSendMailBoot(); + + const items = useMemo( + () => + invoiceMailState?.entries?.map((entry: any) => ({ + quantity: entry.quantity, + total: entry.totalFormatted, + label: entry.name, + })), + [invoiceMailState?.entries], + ); + + const mailReceiptPreviewProps = { + companyName: invoiceMailState?.companyName, + companyLogoUri: invoiceMailState?.companyLogoUri, + primaryColor: invoiceMailState?.primaryColor, + total: invoiceMailState?.totalFormatted, + dueDate: invoiceMailState?.dueDateFormatted, + dueAmount: invoiceMailState?.dueAmountFormatted, + invoiceNumber: invoiceMailState?.invoiceNo, + items, + message, + }; + return ; + }; +}; + +export const InvoiceMailReceiptPreviewWithProps = + withInvoiceMailReceiptPreviewProps(InvoiceMailReceiptPreview); diff --git a/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/InvoiceSendMailDrawer.tsx b/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/InvoiceSendMailDrawer.tsx index 237f37149..2df27d89f 100644 --- a/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/InvoiceSendMailDrawer.tsx +++ b/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/InvoiceSendMailDrawer.tsx @@ -1,7 +1,8 @@ +// @ts-nocheck +import React from 'react'; import * as R from 'ramda'; import { Drawer, DrawerSuspense } from '@/components'; import withDrawers from '@/containers/Drawer/withDrawers'; -import React from 'react'; const InvoiceSendMailContent = React.lazy(() => import('./InvoiceSendMailContent').then((module) => ({ diff --git a/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/InvoiceSendMailPreview.tsx b/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/InvoiceSendMailPreview.tsx index a8fb9d2dc..bf6237365 100644 --- a/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/InvoiceSendMailPreview.tsx +++ b/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/InvoiceSendMailPreview.tsx @@ -3,9 +3,9 @@ import { css } from '@emotion/css'; import { Tab, Tabs } from '@blueprintjs/core'; import { Stack } from '@/components'; -const InvoiceMailReceiptPreviewConneceted = lazy(() => - import('./InvoiceMailReceiptPreviewConnected.').then((module) => ({ - default: module.InvoiceMailReceiptPreviewConneceted, +const InvoiceMailReceiptPreviewConnected = lazy(() => + import('./InvoiceMailReceiptPreviewConnected').then((module) => ({ + default: module.InvoiceMailReceiptPreviewConnected, })), ); const InvoiceSendPdfPreviewConnected = lazy(() => @@ -51,7 +51,7 @@ export function InvoiceSendMailPreview() { title={'Payment page'} panel={ - + } />