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

@@ -0,0 +1,41 @@
// @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 GeneralLedgerPdfDialogContent = lazy(
() => import('./GeneralLedgerPdfDialogContent'),
);
/**
* General ledger pdf preview dialog.
* @returns {React.ReactNode}
*/
function GeneralLedgerPdfDialogRoot({ dialogName, payload, isOpen }) {
return (
<Dialog
name={dialogName}
title={'General Ledger PDF Preview'}
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
autoFocus={true}
canEscapeKeyClose={true}
isOpen={isOpen}
style={{ width: '1000px' }}
>
<DialogSuspense>
<GeneralLedgerPdfDialogContent />
</DialogSuspense>
</Dialog>
);
}
export const GeneralLedgerPdfDialog = compose(withDialogRedux())(
GeneralLedgerPdfDialogRoot,
);

View File

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