feat(webapp): wip printing financial reports

This commit is contained in:
Ahmed Bouhuolia
2024-02-12 19:07:57 +02:00
parent eb4491f44a
commit d229378957
80 changed files with 1424 additions and 25 deletions

View File

@@ -15,6 +15,7 @@ import {
} from './components';
import { InventoryItemDetailsBody } from './InventoryItemDetailsBody';
import { InventoryItemDetailsDialogs } from './InventoryItemDetailsDialogs';
import { useInventoryValuationQuery } from './utils2';
import { compose } from '@/utils';
@@ -64,6 +65,8 @@ function InventoryItemDetails({
<InventoryItemDetailsBody />
</FinancialStatement>
</DashboardPageContent>
<InventoryItemDetailsDialogs />
</InventoryItemDetailsProvider>
);
}

View File

@@ -20,6 +20,8 @@ import withInventoryItemDetails from './withInventoryItemDetails';
import withInventoryItemDetailsActions from './withInventoryItemDetailsActions';
import { compose, saveInvoke } from '@/utils';
import { DialogsName } from '@/constants/dialogs';
import withDialogActions from '@/containers/Dialog/withDialogActions';
/**
* Inventory item details actions bar.
@@ -32,6 +34,9 @@ function InventoryItemDetailsActionsBar({
//#withInventoryItemDetails
isFilterDrawerOpen,
// #withDialogActions
openDialog,
//#withInventoryItemDetailsActions
toggleInventoryItemDetailsFilterDrawer: toggleFilterDrawer,
}) {
@@ -50,7 +55,10 @@ function InventoryItemDetailsActionsBar({
const handleNumberFormatSubmit = (values) => {
saveInvoke(onNumberFormatSubmit, values);
};
// Handle print button click.
const handlePrintBtnClick = () => {
openDialog(DialogsName.InventoryItemDetailsPdfPreview);
};
return (
<DashboardActionsBar>
<NavbarGroup>
@@ -112,6 +120,7 @@ function InventoryItemDetailsActionsBar({
className={Classes.MINIMAL}
icon={<Icon icon="print-16" iconSize={16} />}
text={<T id={'print'} />}
onClick={handlePrintBtnClick}
/>
<Popover
content={<InventoryItemDetailsExportMenu />}
@@ -135,4 +144,5 @@ export default compose(
isFilterDrawerOpen: inventoryItemDetailDrawerFilter,
})),
withInventoryItemDetailsActions,
withDialogActions,
)(InventoryItemDetailsActionsBar);

View File

@@ -0,0 +1,12 @@
import { DialogsName } from '@/constants/dialogs';
import { InventoryItemDetailsPdfDialog } from './dialogs/InventoryItemDetailsPdfDialog';
export function InventoryItemDetailsDialogs() {
return (
<>
<InventoryItemDetailsPdfDialog
dialogName={DialogsName.InventoryItemDetailsPdfPreview}
/>
</>
);
}

View File

@@ -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 InventoryItemDetailsPdfDialogContent = lazy(
() => import('./InventoryItemDetailsPdfDialogContent'),
);
/**
* Inventory item details sheet pdf preview dialog.
* @returns {React.ReactNode}
*/
function InventoryItemDetailsPdfDialogRoot({ dialogName, payload, isOpen }) {
return (
<Dialog
name={dialogName}
title={'Inventory Item Details Print Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true}
canEscapeKeyClose={true}
isOpen={isOpen}
style={{ width: '1000px' }}
>
<DialogSuspense>
<InventoryItemDetailsPdfDialogContent dialogName={dialogName} />
</DialogSuspense>
</Dialog>
);
}
export const InventoryItemDetailsPdfDialog = compose(withDialogRedux())(
InventoryItemDetailsPdfDialogRoot,
);

View File

@@ -0,0 +1,42 @@
import {
DialogContent,
PdfDocumentPreview,
FormattedMessage as T,
} from '@/components';
import { useInventoryItemDetailsPdf } from '@/hooks/query';
import { AnchorButton } from '@blueprintjs/core';
export default function InventoryItemDetailsPdfDialogContent() {
const { isLoading, pdfUrl } = useInventoryItemDetailsPdf();
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>
);
}

View File

@@ -0,0 +1 @@
export * from './InventoryItemDetailsPdfDialog';