mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
feat: Payment invoice preview drawer
This commit is contained in:
@@ -4,9 +4,10 @@ import { FormattedMessage as T } from '@/components';
|
|||||||
import { Classes, Icon, H4, Button } from '@blueprintjs/core';
|
import { Classes, Icon, H4, Button } from '@blueprintjs/core';
|
||||||
|
|
||||||
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
||||||
|
import { useDrawerContext } from './DrawerProvider';
|
||||||
|
|
||||||
import styled from 'styled-components';
|
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Drawer header content.
|
* Drawer header content.
|
||||||
@@ -16,18 +17,15 @@ function DrawerHeaderContentRoot(props) {
|
|||||||
icon,
|
icon,
|
||||||
title = <T id={'view_paper'} />,
|
title = <T id={'view_paper'} />,
|
||||||
subTitle,
|
subTitle,
|
||||||
onClose,
|
|
||||||
name,
|
|
||||||
closeDrawer,
|
closeDrawer,
|
||||||
} = props;
|
} = props;
|
||||||
|
const { name } = useDrawerContext();
|
||||||
|
|
||||||
if (title == null) {
|
if (title == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleClose = (event) => {
|
const handleClose = (event) => {
|
||||||
closeDrawer(name);
|
closeDrawer(name);
|
||||||
onClose && onClose(event);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -31,5 +31,6 @@ export enum DRAWERS {
|
|||||||
RECEIPT_CUSTOMIZE = 'RECEIPT_CUSTOMIZE',
|
RECEIPT_CUSTOMIZE = 'RECEIPT_CUSTOMIZE',
|
||||||
CREDIT_NOTE_CUSTOMIZE = 'CREDIT_NOTE_CUSTOMIZE',
|
CREDIT_NOTE_CUSTOMIZE = 'CREDIT_NOTE_CUSTOMIZE',
|
||||||
PAYMENT_RECEIVED_CUSTOMIZE = 'PAYMENT_RECEIVED_CUSTOMIZE',
|
PAYMENT_RECEIVED_CUSTOMIZE = 'PAYMENT_RECEIVED_CUSTOMIZE',
|
||||||
BRANDING_TEMPLATES = 'BRANDING_TEMPLATES'
|
BRANDING_TEMPLATES = 'BRANDING_TEMPLATES',
|
||||||
|
PAYMENT_INVOICE_PREVIEW = 'PAYMENT_INVOICE_PREVIEW'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,17 @@ import clsx from 'classnames';
|
|||||||
import { Box, Group, Stack } from '@/components';
|
import { Box, Group, Stack } from '@/components';
|
||||||
import styles from './PaymentPortal.module.scss';
|
import styles from './PaymentPortal.module.scss';
|
||||||
import { usePaymentPortalBoot } from './PaymentPortalBoot';
|
import { usePaymentPortalBoot } from './PaymentPortalBoot';
|
||||||
|
import { useDrawerActions } from '@/hooks/state';
|
||||||
|
import { DRAWERS } from '@/constants/drawers';
|
||||||
|
|
||||||
export function PaymentPortal() {
|
export function PaymentPortal() {
|
||||||
|
const { openDrawer } = useDrawerActions();
|
||||||
const { sharableLinkMeta } = usePaymentPortalBoot();
|
const { sharableLinkMeta } = usePaymentPortalBoot();
|
||||||
|
|
||||||
|
const handleInvoicePreviewBtnClick = () => {
|
||||||
|
openDrawer(DRAWERS.PAYMENT_INVOICE_PREVIEW);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className={styles.root}>
|
<Box className={styles.root}>
|
||||||
<Stack spacing={0} className={styles.body}>
|
<Stack spacing={0} className={styles.body}>
|
||||||
@@ -85,6 +92,7 @@ export function PaymentPortal() {
|
|||||||
Download Invoice
|
Download Invoice
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
|
onClick={handleInvoicePreviewBtnClick}
|
||||||
className={clsx(styles.footerButton, styles.viewInvoiceButton)}
|
className={clsx(styles.footerButton, styles.viewInvoiceButton)}
|
||||||
>
|
>
|
||||||
View Invoice
|
View Invoice
|
||||||
|
|||||||
@@ -3,15 +3,21 @@ import { PaymentPortal } from './PaymentPortal';
|
|||||||
import { PaymentPortalBoot } from './PaymentPortalBoot';
|
import { PaymentPortalBoot } from './PaymentPortalBoot';
|
||||||
import BodyClassName from 'react-body-classname';
|
import BodyClassName from 'react-body-classname';
|
||||||
import styles from './PaymentPortal.module.scss';
|
import styles from './PaymentPortal.module.scss';
|
||||||
|
import { PaymentInvoicePreviewDrawer } from './drawers/PaymentInvoicePreviewDrawer/PaymentInvoicePreviewDrawer';
|
||||||
|
import { DRAWERS } from '@/constants/drawers';
|
||||||
|
|
||||||
export default function PaymentPortalPage() {
|
export default function PaymentPortalPage() {
|
||||||
const { linkId } = useParams<{ linkId: string }>();
|
const { linkId } = useParams<{ linkId: string }>();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BodyClassName className={styles.rootBodyPage}>
|
<>
|
||||||
<PaymentPortalBoot linkId={linkId}>
|
<BodyClassName className={styles.rootBodyPage}>
|
||||||
<PaymentPortal />
|
<PaymentPortalBoot linkId={linkId}>
|
||||||
</PaymentPortalBoot>
|
<PaymentPortal />
|
||||||
</BodyClassName>
|
</PaymentPortalBoot>
|
||||||
|
</BodyClassName>
|
||||||
|
|
||||||
|
<PaymentInvoicePreviewDrawer name={DRAWERS.PAYMENT_INVOICE_PREVIEW} />
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
// @ts-nocheck
|
||||||
|
import { Box, DrawerBody, DrawerHeaderContent } from '@/components';
|
||||||
|
import { InvoicePaperTemplate } from '@/containers/Sales/Invoices/InvoiceCustomize/InvoicePaperTemplate';
|
||||||
|
|
||||||
|
export function PaymentInvoicePreviewContent() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<DrawerHeaderContent title={'Invoice'} />
|
||||||
|
|
||||||
|
<DrawerBody>
|
||||||
|
<Box style={{ paddingTop: 20, paddingBottom: 20 }}>
|
||||||
|
<InvoicePaperTemplate />
|
||||||
|
</Box>
|
||||||
|
</DrawerBody>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
// @ts-nocheck
|
||||||
|
import React from 'react';
|
||||||
|
import * as R from 'ramda';
|
||||||
|
import { Drawer, DrawerSuspense } from '@/components';
|
||||||
|
import withDrawers from '@/containers/Drawer/withDrawers';
|
||||||
|
import { PaymentInvoicePreviewContent } from './PaymentInvoicePreviewContent';
|
||||||
|
import { Position } from '@blueprintjs/core';
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {React.ReactNode}
|
||||||
|
*/
|
||||||
|
function PaymentInvoicePreviewDrawerRoot({
|
||||||
|
name,
|
||||||
|
// #withDrawer
|
||||||
|
isOpen,
|
||||||
|
payload,
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Drawer
|
||||||
|
isOpen={isOpen}
|
||||||
|
name={name}
|
||||||
|
size={'100%'}
|
||||||
|
style={{ background: '#F6F7F9' }}
|
||||||
|
position={Position.TOP}
|
||||||
|
payload={payload}
|
||||||
|
>
|
||||||
|
<DrawerSuspense>
|
||||||
|
<PaymentInvoicePreviewContent />
|
||||||
|
</DrawerSuspense>
|
||||||
|
</Drawer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PaymentInvoicePreviewDrawer = R.compose(withDrawers())(
|
||||||
|
PaymentInvoicePreviewDrawerRoot,
|
||||||
|
);
|
||||||
@@ -73,13 +73,13 @@ export interface InvoicePaperTemplateProps {
|
|||||||
balanceDue?: string;
|
balanceDue?: string;
|
||||||
|
|
||||||
// Footer
|
// Footer
|
||||||
termsConditionsLabel: string;
|
termsConditionsLabel?: string;
|
||||||
showTermsConditions: boolean;
|
showTermsConditions?: boolean;
|
||||||
termsConditions: string;
|
termsConditions?: string;
|
||||||
|
|
||||||
statementLabel: string;
|
statementLabel?: string;
|
||||||
showStatement: boolean;
|
showStatement?: boolean;
|
||||||
statement: string;
|
statement?: string;
|
||||||
|
|
||||||
lines?: Array<PapaerLine>;
|
lines?: Array<PapaerLine>;
|
||||||
taxes?: Array<PaperTax>;
|
taxes?: Array<PaperTax>;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
import { useProjects } from '@/containers/Projects/hooks';
|
import { useProjects } from '@/containers/Projects/hooks';
|
||||||
import { useTaxRates } from '@/hooks/query/taxRates';
|
import { useTaxRates } from '@/hooks/query/taxRates';
|
||||||
import { useGetPdfTemplates } from '@/hooks/query/pdf-templates';
|
import { useGetPdfTemplates } from '@/hooks/query/pdf-templates';
|
||||||
|
import { useGetPaymentServices } from '@/hooks/query/payment-services';
|
||||||
|
|
||||||
const InvoiceFormContext = createContext();
|
const InvoiceFormContext = createContext();
|
||||||
|
|
||||||
@@ -60,6 +61,10 @@ function InvoiceFormProvider({ invoiceId, baseCurrency, ...props }) {
|
|||||||
const { data: brandingTemplates, isLoading: isBrandingTemplatesLoading } =
|
const { data: brandingTemplates, isLoading: isBrandingTemplatesLoading } =
|
||||||
useGetPdfTemplates({ resource: 'SaleInvoice' });
|
useGetPdfTemplates({ resource: 'SaleInvoice' });
|
||||||
|
|
||||||
|
// Fetches the payment services.
|
||||||
|
const { data: paymentServices, isLoading: isPaymentServicesLoading } =
|
||||||
|
useGetPaymentServices();
|
||||||
|
|
||||||
const newInvoice = !isEmpty(estimate)
|
const newInvoice = !isEmpty(estimate)
|
||||||
? transformToEditForm({
|
? transformToEditForm({
|
||||||
...pick(estimate, ['customer_id', 'currency_code', 'entries']),
|
...pick(estimate, ['customer_id', 'currency_code', 'entries']),
|
||||||
@@ -110,7 +115,10 @@ function InvoiceFormProvider({ invoiceId, baseCurrency, ...props }) {
|
|||||||
|
|
||||||
// Determines whether the warehouse and branches are loading.
|
// Determines whether the warehouse and branches are loading.
|
||||||
const isFeatureLoading =
|
const isFeatureLoading =
|
||||||
isWarehouesLoading || isBranchesLoading || isProjectsLoading || isBrandingTemplatesLoading;
|
isWarehouesLoading ||
|
||||||
|
isBranchesLoading ||
|
||||||
|
isProjectsLoading ||
|
||||||
|
isBrandingTemplatesLoading;
|
||||||
|
|
||||||
const provider = {
|
const provider = {
|
||||||
invoice,
|
invoice,
|
||||||
|
|||||||
Reference in New Issue
Block a user