mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
feat(webapp): wip printing financial reports
This commit is contained in:
@@ -13,6 +13,7 @@ import { usePurchasesByItemsQuery } from './utils';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
import withPurchasesByItemsActions from './withPurchasesByItemsActions';
|
||||
import { PurchasesByItemsDialogs } from './PurchasesByItemsDialogs';
|
||||
|
||||
/**
|
||||
* Purchases by items.
|
||||
@@ -67,6 +68,8 @@ function PurchasesByItems({
|
||||
<PurchasesByItemsBody />
|
||||
</FinancialStatement>
|
||||
</DashboardPageContent>
|
||||
|
||||
<PurchasesByItemsDialogs />
|
||||
</PurchasesByItemsProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,11 @@ import NumberFormatDropdown from '@/components/NumberFormatDropdown';
|
||||
|
||||
import withPurchasesByItems from './withPurchasesByItems';
|
||||
import withPurchasesByItemsActions from './withPurchasesByItemsActions';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { compose, saveInvoke } from '@/utils';
|
||||
import { usePurchaseByItemsContext } from './PurchasesByItemsProvider';
|
||||
import { PurchasesByItemsExportMenu } from './components';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
|
||||
function PurchasesByItemsActionsBar({
|
||||
// #withPurchasesByItems
|
||||
@@ -27,6 +29,9 @@ function PurchasesByItemsActionsBar({
|
||||
// #withPurchasesByItemsActions
|
||||
togglePurchasesByItemsFilterDrawer,
|
||||
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
// #ownProps
|
||||
numberFormat,
|
||||
onNumberFormatSubmit,
|
||||
@@ -48,6 +53,11 @@ function PurchasesByItemsActionsBar({
|
||||
saveInvoke(onNumberFormatSubmit, values);
|
||||
};
|
||||
|
||||
// Handle print button click.
|
||||
const handlePrintBtnClick = () => {
|
||||
openDialog(DialogsName.PurchasesByItemsPdfPreview);
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
<NavbarGroup>
|
||||
@@ -106,6 +116,7 @@ function PurchasesByItemsActionsBar({
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="print-16" iconSize={16} />}
|
||||
text={<T id={'print'} />}
|
||||
onClick={handlePrintBtnClick}
|
||||
/>
|
||||
<Popover
|
||||
content={<PurchasesByItemsExportMenu />}
|
||||
@@ -129,4 +140,5 @@ export default compose(
|
||||
purchasesByItemsDrawerFilter,
|
||||
})),
|
||||
withPurchasesByItemsActions,
|
||||
withDialogActions,
|
||||
)(PurchasesByItemsActionsBar);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
import { PurchasesByItemsPdfDialog } from './dialogs/PurchasesByItemsDialog';
|
||||
|
||||
export function PurchasesByItemsDialogs() {
|
||||
return (
|
||||
<>
|
||||
<PurchasesByItemsPdfDialog
|
||||
dialogName={DialogsName.PurchasesByItemsPdfPreview}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -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 PurchasesByItemsPdfDialogContent = lazy(
|
||||
() => import('./PurchasesByItemsPdfDialogContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Purchases by items sheet pdf preview dialog.
|
||||
* @returns {React.ReactNode}
|
||||
*/
|
||||
function PurchasesByItemsPdfDialogRoot({ dialogName, payload, isOpen }) {
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
title={'Purchases By Items Print Preview'}
|
||||
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
|
||||
autoFocus={true}
|
||||
canEscapeKeyClose={true}
|
||||
isOpen={isOpen}
|
||||
style={{ width: '1000px' }}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<PurchasesByItemsPdfDialogContent />
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export const PurchasesByItemsPdfDialog = compose(withDialogRedux())(
|
||||
PurchasesByItemsPdfDialogRoot,
|
||||
);
|
||||
@@ -0,0 +1,42 @@
|
||||
import { AnchorButton } from '@blueprintjs/core';
|
||||
import {
|
||||
DialogContent,
|
||||
PdfDocumentPreview,
|
||||
FormattedMessage as T,
|
||||
} from '@/components';
|
||||
import { usePurchasesByItemsPdfExport } from '@/hooks/query';
|
||||
|
||||
export default function PurchasesByItemsPdfDialogContent() {
|
||||
const { isLoading, pdfUrl } = usePurchasesByItemsPdfExport();
|
||||
|
||||
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 './PurchasesByItemsPdfDialog';
|
||||
Reference in New Issue
Block a user