mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
feat(webapp): wip printing financial reports
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// @ts-nocheck
|
||||
import React, { lazy } from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { Dialog, DialogSuspense } from '@/components';
|
||||
|
||||
import withDialogRedux from '@/components/DialogReduxConnect';
|
||||
|
||||
import { CLASSES } from '@/constants/classes';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
// Lazy loading the content.
|
||||
const CustomerBalanceSummaryPdfDialogContent = lazy(
|
||||
() => import('./CustomerBalanceSummaryPdfDialogContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Cashflow sheet pdf preview dialog.
|
||||
* @returns {React.ReactNode}
|
||||
*/
|
||||
function CashflowSheetPdfDialogRoot({ dialogName, payload, isOpen }) {
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
title={'Customer Balance Summary Print Preview'}
|
||||
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
|
||||
autoFocus={true}
|
||||
canEscapeKeyClose={true}
|
||||
isOpen={isOpen}
|
||||
style={{ width: '1000px' }}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<CustomerBalanceSummaryPdfDialogContent />
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export const CustomerBalanceSummaryPdfDialog = compose(withDialogRedux())(
|
||||
CashflowSheetPdfDialogRoot,
|
||||
);
|
||||
@@ -0,0 +1,42 @@
|
||||
import {
|
||||
DialogContent,
|
||||
PdfDocumentPreview,
|
||||
FormattedMessage as T,
|
||||
} from '@/components';
|
||||
import { AnchorButton } from '@blueprintjs/core';
|
||||
import { useCustomerBalanceSummaryPdf } from '@/hooks/query';
|
||||
|
||||
export default function CustomerBalanceSummaryPdfDialogContent() {
|
||||
const { isLoading, pdfUrl } = useCustomerBalanceSummaryPdf();
|
||||
|
||||
return (
|
||||
<DialogContent>
|
||||
<div className="dialog__header-actions">
|
||||
<AnchorButton
|
||||
href={pdfUrl}
|
||||
target={'__blank'}
|
||||
minimal={true}
|
||||
outlined={true}
|
||||
>
|
||||
<T id={'pdf_preview.preview.button'} />
|
||||
</AnchorButton>
|
||||
|
||||
<AnchorButton
|
||||
href={pdfUrl}
|
||||
download={'invoice.pdf'}
|
||||
minimal={true}
|
||||
outlined={true}
|
||||
>
|
||||
<T id={'pdf_preview.download.button'} />
|
||||
</AnchorButton>
|
||||
</div>
|
||||
|
||||
<PdfDocumentPreview
|
||||
height={760}
|
||||
width={1000}
|
||||
isLoading={isLoading}
|
||||
url={pdfUrl}
|
||||
/>
|
||||
</DialogContent>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from './CustomerBalanceSummaryPdfDialog';
|
||||
@@ -13,6 +13,8 @@ import { CustomersBalanceSummaryProvider } from './CustomersBalanceSummaryProvid
|
||||
import { useCustomerBalanceSummaryQuery } from './utils';
|
||||
import { CustomersBalanceLoadingBar } from './components';
|
||||
import withCustomersBalanceSummaryActions from './withCustomersBalanceSummaryActions';
|
||||
import { CustomerBalanceSummaryPdfDialog } from './CustomerBalancePdfDialog';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
|
||||
/**
|
||||
* Customers Balance summary.
|
||||
@@ -61,6 +63,10 @@ function CustomersBalanceSummary({
|
||||
<CustomerBalanceSummaryBody />
|
||||
</FinancialStatement>
|
||||
</DashboardPageContent>
|
||||
|
||||
<CustomerBalanceSummaryPdfDialog
|
||||
dialogName={DialogsName.CustomerBalanceSummaryPdfPreview}
|
||||
/>
|
||||
</CustomersBalanceSummaryProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ import withCustomersBalanceSummaryActions from './withCustomersBalanceSummaryAct
|
||||
import { useCustomersBalanceSummaryContext } from './CustomersBalanceSummaryProvider';
|
||||
import { compose, saveInvoke } from '@/utils';
|
||||
import { CustomerBalanceSummaryExportMenu } from './components';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
|
||||
/**
|
||||
* customer balance summary action bar.
|
||||
@@ -32,6 +34,9 @@ function CustomersBalanceSummaryActionsBar({
|
||||
|
||||
//#withCustomersBalanceSummaryActions
|
||||
toggleCustomerBalanceFilterDrawer,
|
||||
|
||||
// #withDialogActions
|
||||
openDialog
|
||||
}) {
|
||||
const { refetch, isCustomersBalanceLoading } =
|
||||
useCustomersBalanceSummaryContext();
|
||||
@@ -51,6 +56,11 @@ function CustomersBalanceSummaryActionsBar({
|
||||
saveInvoke(onNumberFormatSubmit, values);
|
||||
};
|
||||
|
||||
// Handle the print button click.
|
||||
const handlePrintBtnClick = () => {
|
||||
openDialog(DialogsName.CustomerBalanceSummaryPdfPreview);
|
||||
}
|
||||
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
<NavbarGroup>
|
||||
@@ -112,6 +122,7 @@ function CustomersBalanceSummaryActionsBar({
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="print-16" iconSize={16} />}
|
||||
text={<T id={'print'} />}
|
||||
onClick={handlePrintBtnClick}
|
||||
/>
|
||||
<Popover
|
||||
content={<CustomerBalanceSummaryExportMenu />}
|
||||
@@ -134,4 +145,5 @@ export default compose(
|
||||
isFilterDrawerOpen: customersBalanceDrawerFilter,
|
||||
})),
|
||||
withCustomersBalanceSummaryActions,
|
||||
withDialogActions
|
||||
)(CustomersBalanceSummaryActionsBar);
|
||||
|
||||
Reference in New Issue
Block a user