mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
feat(webapp): wip printing financial reports
This commit is contained in:
@@ -15,6 +15,7 @@ import withJournalActions from './withJournalActions';
|
||||
|
||||
import { useJournalQuery } from './utils';
|
||||
import { compose } from '@/utils';
|
||||
import { JournalDialogs } from './JournalDialogs';
|
||||
|
||||
/**
|
||||
* Journal sheet.
|
||||
@@ -23,7 +24,7 @@ function Journal({
|
||||
// #withJournalActions
|
||||
toggleJournalSheetFilter,
|
||||
}) {
|
||||
const {query, setLocationQuery} = useJournalQuery();
|
||||
const { query, setLocationQuery } = useJournalQuery();
|
||||
|
||||
// Handle financial statement filter change.
|
||||
const handleFilterSubmit = useCallback(
|
||||
@@ -60,6 +61,8 @@ function Journal({
|
||||
<JournalBody />
|
||||
</FinancialStatement>
|
||||
</DashboardPageContent>
|
||||
|
||||
<JournalDialogs />
|
||||
</JournalSheetProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ import withJournal from './withJournal';
|
||||
import { compose } from '@/utils';
|
||||
import { useJournalSheetContext } from './JournalProvider';
|
||||
import { JournalSheetExportMenu } from './components';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
|
||||
/**
|
||||
* Journal sheeet - Actions bar.
|
||||
@@ -29,6 +31,9 @@ function JournalActionsBar({
|
||||
|
||||
// #withJournalActions
|
||||
toggleJournalSheetFilter,
|
||||
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
}) {
|
||||
const { refetchSheet } = useJournalSheetContext();
|
||||
|
||||
@@ -42,6 +47,11 @@ function JournalActionsBar({
|
||||
refetchSheet();
|
||||
};
|
||||
|
||||
// Handle the print button click.
|
||||
const handlePrintBtnClick = () => {
|
||||
openDialog(DialogsName.JournalPdfPreview);
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
<NavbarGroup>
|
||||
@@ -85,6 +95,7 @@ function JournalActionsBar({
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="print-16" iconSize={16} />}
|
||||
text={<T id={'print'} />}
|
||||
onClick={handlePrintBtnClick}
|
||||
/>
|
||||
<Popover
|
||||
content={<JournalSheetExportMenu />}
|
||||
@@ -108,4 +119,5 @@ export default compose(
|
||||
isFilterDrawerOpen: journalSheetDrawerFilter,
|
||||
})),
|
||||
withJournalActions,
|
||||
withDialogActions,
|
||||
)(JournalActionsBar);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
import { JournalPdfDialog } from './dialogs/JournalPdfDialog';
|
||||
|
||||
export function JournalDialogs() {
|
||||
return (
|
||||
<>
|
||||
<JournalPdfDialog dialogName={DialogsName.JournalPdfPreview} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// @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 JournalPdfDialogContent = lazy(
|
||||
() => import('./JournalPdfDialogContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Journal sheet pdf preview dialog.
|
||||
* @returns {React.ReactNode}
|
||||
*/
|
||||
function JournalPdfDialogRoot({ dialogName, payload, isOpen }) {
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
title={'Journal Print Preview'}
|
||||
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
|
||||
autoFocus={true}
|
||||
canEscapeKeyClose={true}
|
||||
isOpen={isOpen}
|
||||
style={{ width: '1000px' }}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<JournalPdfDialogContent dialogName={dialogName} />
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export const JournalPdfDialog = compose(withDialogRedux())(
|
||||
JournalPdfDialogRoot,
|
||||
);
|
||||
@@ -0,0 +1,42 @@
|
||||
import {
|
||||
DialogContent,
|
||||
PdfDocumentPreview,
|
||||
FormattedMessage as T,
|
||||
} from '@/components';
|
||||
import { useJournalSheetPdf } from '@/hooks/query';
|
||||
import { AnchorButton } from '@blueprintjs/core';
|
||||
|
||||
export default function JournalSheetPdfDialogContent() {
|
||||
const { isLoading, pdfUrl } = useJournalSheetPdf();
|
||||
|
||||
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={'journal.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 './JournalPdfDialog';
|
||||
Reference in New Issue
Block a user