mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feat(webapp): wip print preview financial reports
This commit is contained in:
@@ -20,6 +20,8 @@ import withProfitLoss from './withProfitLoss';
|
||||
import { compose, saveInvoke } from '@/utils';
|
||||
import { useProfitLossSheetContext } from './ProfitLossProvider';
|
||||
import { ProfitLossSheetExportMenu } from './components';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
|
||||
/**
|
||||
* Profit/Loss sheet actions bar.
|
||||
@@ -31,6 +33,9 @@ function ProfitLossActionsBar({
|
||||
// #withProfitLossActions
|
||||
toggleProfitLossFilterDrawer: toggleFilterDrawer,
|
||||
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
// #ownProps
|
||||
numberFormat,
|
||||
onNumberFormatSubmit,
|
||||
@@ -48,6 +53,10 @@ function ProfitLossActionsBar({
|
||||
const handleNumberFormatSubmit = (values) => {
|
||||
saveInvoke(onNumberFormatSubmit, values);
|
||||
};
|
||||
// Handles the print button click.
|
||||
const handlePrintBtnClick = () => {
|
||||
openDialog(DialogsName.ProfitLossSheetPdfPreview);
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
@@ -110,6 +119,7 @@ function ProfitLossActionsBar({
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="print-16" iconSize={16} />}
|
||||
text={<T id={'print'} />}
|
||||
onClick={handlePrintBtnClick}
|
||||
/>
|
||||
<Popover
|
||||
content={<ProfitLossSheetExportMenu />}
|
||||
@@ -131,4 +141,5 @@ function ProfitLossActionsBar({
|
||||
export default compose(
|
||||
withProfitLoss(({ profitLossDrawerFilter }) => ({ profitLossDrawerFilter })),
|
||||
withProfitLossActions,
|
||||
withDialogActions,
|
||||
)(ProfitLossActionsBar);
|
||||
|
||||
@@ -15,6 +15,7 @@ import { useProfitLossSheetQuery } from './utils';
|
||||
import { ProfitLossSheetProvider } from './ProfitLossProvider';
|
||||
import { ProfitLossSheetAlerts, ProfitLossSheetLoadingBar } from './components';
|
||||
import { ProfitLossBody } from './ProfitLossBody';
|
||||
import { ProfitLossSheetDialogs } from './ProfitLossSheetDialogs';
|
||||
|
||||
/**
|
||||
* Profit/Loss financial statement sheet.
|
||||
@@ -67,6 +68,8 @@ function ProfitLossSheet({
|
||||
/>
|
||||
<ProfitLossBody />
|
||||
</DashboardPageContent>
|
||||
|
||||
<ProfitLossSheetDialogs />
|
||||
</ProfitLossSheetProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
import { ProfitLossSheetPdfDialog } from './ProfitLossSheetPdfDialog';
|
||||
|
||||
export function ProfitLossSheetDialogs() {
|
||||
return (
|
||||
<ProfitLossSheetPdfDialog
|
||||
dialogName={DialogsName.ProfitLossSheetPdfPreview}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -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 ProfitLossSheetPdfDialogContent = lazy(
|
||||
() => import('./ProfitLossSheetPdfDialogContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Cashflow sheet pdf preview dialog.
|
||||
* @returns {React.ReactNode}
|
||||
*/
|
||||
function ProfitLossSheetPdfDialogRoot({ dialogName, payload, isOpen }) {
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
title={'Profit/LossSheet Print Preview'}
|
||||
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
|
||||
autoFocus={true}
|
||||
canEscapeKeyClose={true}
|
||||
isOpen={isOpen}
|
||||
style={{ width: '1000px' }}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<ProfitLossSheetPdfDialogContent
|
||||
dialogName={dialogName}
|
||||
subscriptionForm={payload}
|
||||
/>
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export const ProfitLossSheetPdfDialog = compose(withDialogRedux())(
|
||||
ProfitLossSheetPdfDialogRoot,
|
||||
);
|
||||
@@ -0,0 +1,42 @@
|
||||
import {
|
||||
DialogContent,
|
||||
PdfDocumentPreview,
|
||||
FormattedMessage as T,
|
||||
} from '@/components';
|
||||
import { AnchorButton } from '@blueprintjs/core';
|
||||
import { useProfitLossSheetPdf } from '@/hooks/query';
|
||||
|
||||
export default function ProfitLossSheetPdfDialogContent() {
|
||||
const { isLoading, pdfUrl } = useProfitLossSheetPdf();
|
||||
|
||||
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 './ProfitLossSheetPdfDialog';
|
||||
Reference in New Issue
Block a user