mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
feat(webapp): wip printing financial reports
This commit is contained in:
@@ -14,6 +14,7 @@ import { CustomersTransactionsProvider } from './CustomersTransactionsProvider';
|
||||
|
||||
import { compose } from '@/utils';
|
||||
import { useCustomersTransactionsQuery } from './_utils';
|
||||
import { CustomersTransactionsDialogs } from './CustomersTransactionsDialogs';
|
||||
|
||||
/**
|
||||
* Customers transactions.
|
||||
@@ -65,6 +66,8 @@ function CustomersTransactions({
|
||||
<CustomersTransactionsBody />
|
||||
</FinancialStatement>
|
||||
</DashboardPageContent>
|
||||
|
||||
<CustomersTransactionsDialogs />
|
||||
</CustomersTransactionsProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import withCustomersTransactions from './withCustomersTransactions';
|
||||
import withCustomersTransactionsActions from './withCustomersTransactionsActions';
|
||||
|
||||
import { compose, saveInvoke } from '@/utils';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
|
||||
/**
|
||||
* Customers transactions actions bar.
|
||||
@@ -34,6 +36,9 @@ function CustomersTransactionsActionsBar({
|
||||
|
||||
//#withCustomersTransactionsActions
|
||||
toggleCustomersTransactionsFilterDrawer,
|
||||
|
||||
// #withDialogActions
|
||||
openDialog
|
||||
}) {
|
||||
const { isCustomersTransactionsLoading, CustomersTransactionsRefetch } =
|
||||
useCustomersTransactionsContext();
|
||||
@@ -53,6 +58,11 @@ function CustomersTransactionsActionsBar({
|
||||
saveInvoke(onNumberFormatSubmit, values);
|
||||
};
|
||||
|
||||
// Handle print button click.
|
||||
const handlePrintBtnClick = () => {
|
||||
openDialog(DialogsName.CustomerTransactionsPdfPreview)
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
<NavbarGroup>
|
||||
@@ -114,6 +124,7 @@ function CustomersTransactionsActionsBar({
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="print-16" iconSize={16} />}
|
||||
text={<T id={'print'} />}
|
||||
onClick={handlePrintBtnClick}
|
||||
/>
|
||||
<Popover
|
||||
content={<CustomersTransactionsExportMenu />}
|
||||
@@ -137,4 +148,5 @@ export default compose(
|
||||
isFilterDrawerOpen: customersTransactionsDrawerFilter,
|
||||
})),
|
||||
withCustomersTransactionsActions,
|
||||
withDialogActions
|
||||
)(CustomersTransactionsActionsBar);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
import { CustomerTransactionsPdfDialog } from './dialogs/CustomerTransactionsPdfDialog';
|
||||
|
||||
export function CustomersTransactionsDialogs() {
|
||||
return (
|
||||
<>
|
||||
<CustomerTransactionsPdfDialog
|
||||
dialogName={DialogsName.CustomerTransactionsPdfPreview}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -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 CustomerTransactionsPdfDialogContent = lazy(
|
||||
() => import('./CustomerTransactionsPdfDialogContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Cashflow sheet pdf preview dialog.
|
||||
* @returns {React.ReactNode}
|
||||
*/
|
||||
function CashflowSheetPdfDialogRoot({ dialogName, payload, isOpen }) {
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
title={'Customer Tranasctions PDF Preview'}
|
||||
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
|
||||
autoFocus={true}
|
||||
canEscapeKeyClose={true}
|
||||
isOpen={isOpen}
|
||||
style={{ width: '1000px' }}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<CustomerTransactionsPdfDialogContent />
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export const CustomerTransactionsPdfDialog = compose(withDialogRedux())(
|
||||
CashflowSheetPdfDialogRoot,
|
||||
);
|
||||
@@ -0,0 +1,42 @@
|
||||
import {
|
||||
DialogContent,
|
||||
PdfDocumentPreview,
|
||||
FormattedMessage as T,
|
||||
} from '@/components';
|
||||
import { AnchorButton } from '@blueprintjs/core';
|
||||
import { useCustomersTransactionsPdfExport } from '@/hooks/query';
|
||||
|
||||
export default function CashflowSheetPdfDialogContent() {
|
||||
const { isLoading, pdfUrl } = useCustomersTransactionsPdfExport();
|
||||
|
||||
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 './CustomerTransactionsPdfDialog';
|
||||
Reference in New Issue
Block a user