mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat(webapp): wip print preview financial reports
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
|
||||
import { useCashflowStatementQuery } from './utils';
|
||||
import { compose } from '@/utils';
|
||||
import { CashflowSheetDialogs } from './CashflowSheetDialogs';
|
||||
|
||||
/**
|
||||
* Cash flow statement.
|
||||
@@ -71,6 +72,8 @@ function CashFlowStatement({
|
||||
<CashFlowStatementBody />
|
||||
</FinancialStatement>
|
||||
</DashboardPageContent>
|
||||
|
||||
<CashflowSheetDialogs />
|
||||
</CashFlowStatementProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import withCashFlowStatementActions from './withCashFlowStatementActions';
|
||||
|
||||
import { compose, saveInvoke } from '@/utils';
|
||||
import { CashflowSheetExportMenu } from './components';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
|
||||
/**
|
||||
* Cash flow statement actions bar.
|
||||
@@ -31,6 +33,9 @@ function CashFlowStatementActionsBar({
|
||||
//#withCashStatementActions
|
||||
toggleCashFlowStatementFilterDrawer,
|
||||
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
//#ownProps
|
||||
numberFormat,
|
||||
onNumberFormatSubmit,
|
||||
@@ -51,6 +56,11 @@ function CashFlowStatementActionsBar({
|
||||
const handleNumberFormatSubmit = (values) =>
|
||||
saveInvoke(onNumberFormatSubmit, values);
|
||||
|
||||
// Handle print button click.
|
||||
const handlePrintBtnClick = () => {
|
||||
openDialog(DialogsName.CashflowSheetPdfPreview);
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
<NavbarGroup>
|
||||
@@ -115,6 +125,7 @@ function CashFlowStatementActionsBar({
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="print-16" iconSize={16} />}
|
||||
text={<T id={'print'} />}
|
||||
onClick={handlePrintBtnClick}
|
||||
/>
|
||||
<Popover
|
||||
content={<CashflowSheetExportMenu />}
|
||||
@@ -138,4 +149,5 @@ export default compose(
|
||||
isFilterDrawerOpen: cashFlowStatementDrawerFilter,
|
||||
})),
|
||||
withCashFlowStatementActions,
|
||||
withDialogActions,
|
||||
)(CashFlowStatementActionsBar);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
import { CashflowSheetPdfDialog } from './CashflowSheetPdfDialog';
|
||||
|
||||
export function CashflowSheetDialogs() {
|
||||
return (
|
||||
<>
|
||||
<CashflowSheetPdfDialog
|
||||
dialogName={DialogsName.CashflowSheetPdfPreview}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// @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 CashflowSheetPdfDialogContent = lazy(
|
||||
() => import('./CashflowSheetPdfDialogContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Cashflow sheet pdf preview dialog.
|
||||
* @returns {React.ReactNode}
|
||||
*/
|
||||
function CashflowSheetPdfDialogRoot({ dialogName, payload, isOpen }) {
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
title={'Trial Balance Sheet Print Preview'}
|
||||
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
|
||||
autoFocus={true}
|
||||
canEscapeKeyClose={true}
|
||||
isOpen={isOpen}
|
||||
style={{ width: '1000px' }}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<CashflowSheetPdfDialogContent
|
||||
dialogName={dialogName}
|
||||
subscriptionForm={payload}
|
||||
/>
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export const CashflowSheetPdfDialog = compose(withDialogRedux())(
|
||||
CashflowSheetPdfDialogRoot,
|
||||
);
|
||||
@@ -0,0 +1,42 @@
|
||||
import {
|
||||
DialogContent,
|
||||
PdfDocumentPreview,
|
||||
FormattedMessage as T,
|
||||
} from '@/components';
|
||||
import { AnchorButton } from '@blueprintjs/core';
|
||||
import { useCashflowSheetPdf } from '@/hooks/query';
|
||||
|
||||
export default function CashflowSheetPdfDialogContent() {
|
||||
const { isLoading, pdfUrl } = useCashflowSheetPdf();
|
||||
|
||||
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 './CashflowSheetPdfDialog';
|
||||
Reference in New Issue
Block a user