mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
feat(webapp): wip printing financial reports
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
import { VendorBalancePdfDialog } from './dialogs/VendorBalancePdfDialog';
|
||||
|
||||
export function VendorBalanceDialogs() {
|
||||
return (
|
||||
<>
|
||||
<VendorBalancePdfDialog dialogName={DialogsName.VendorBalancePdfPreview} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// @ts-nocheck
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import moment from 'moment';
|
||||
|
||||
import { FinancialStatement, DashboardPageContent } from '@/components';
|
||||
@@ -14,6 +14,7 @@ import { VendorBalanceSummaryBody } from './VendorsBalanceSummaryBody';
|
||||
import withVendorsBalanceSummaryActions from './withVendorsBalanceSummaryActions';
|
||||
|
||||
import { useVendorsBalanceSummaryQuery } from './utils';
|
||||
import { VendorBalanceDialogs } from './VendorBalanceDialogs';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
/**
|
||||
@@ -64,6 +65,8 @@ function VendorsBalanceSummary({
|
||||
<VendorBalanceSummaryBody />
|
||||
</FinancialStatement>
|
||||
</DashboardPageContent>
|
||||
|
||||
<VendorBalanceDialogs />
|
||||
</VendorsBalanceSummaryProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import { useVendorsBalanceSummaryContext } from './VendorsBalanceSummaryProvider
|
||||
|
||||
import { saveInvoke, compose } from '@/utils';
|
||||
import { VendorSummarySheetExportMenu } from './components';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { DialogsName } from '@/constants/dialogs';
|
||||
|
||||
/**
|
||||
* Vendors balance summary action bar.
|
||||
@@ -34,6 +36,9 @@ function VendorsBalanceSummaryActionsBar({
|
||||
|
||||
// #withVendorsBalanceSummaryActions
|
||||
toggleVendorSummaryFilterDrawer,
|
||||
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
}) {
|
||||
const { isVendorsBalanceLoading, refetch } =
|
||||
useVendorsBalanceSummaryContext();
|
||||
@@ -52,6 +57,11 @@ function VendorsBalanceSummaryActionsBar({
|
||||
saveInvoke(onNumberFormatSubmit, numberFormat);
|
||||
};
|
||||
|
||||
// Handle the print button click.
|
||||
const handlePrintBtnClick = () => {
|
||||
openDialog(DialogsName.VendorBalancePdfPreview);
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
<NavbarGroup>
|
||||
@@ -106,6 +116,7 @@ function VendorsBalanceSummaryActionsBar({
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="print-16" iconSize={16} />}
|
||||
text={<T id={'print'} />}
|
||||
onClick={handlePrintBtnClick}
|
||||
/>
|
||||
<Popover
|
||||
content={<VendorSummarySheetExportMenu />}
|
||||
@@ -128,4 +139,5 @@ export default compose(
|
||||
withVendorsBalanceSummary(({ VendorsSummaryFilterDrawer }) => ({
|
||||
isFilterDrawerOpen: VendorsSummaryFilterDrawer,
|
||||
})),
|
||||
withDialogActions,
|
||||
)(VendorsBalanceSummaryActionsBar);
|
||||
|
||||
@@ -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 VendorBalancePdfDialogContent = lazy(
|
||||
() => import('./VendorBalancePdfDialogContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Vendor balance sheet pdf preview dialog.
|
||||
* @returns {React.ReactNode}
|
||||
*/
|
||||
function VendorBalancePdfDialogRoot({ dialogName, payload, isOpen }) {
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
title={'Vendor Balance Print Preview'}
|
||||
className={classNames(CLASSES.DIALOG_PDF_PREVIEW)}
|
||||
autoFocus={true}
|
||||
canEscapeKeyClose={true}
|
||||
isOpen={isOpen}
|
||||
style={{ width: '1000px' }}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<VendorBalancePdfDialogContent />
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export const VendorBalancePdfDialog = compose(withDialogRedux())(
|
||||
VendorBalancePdfDialogRoot,
|
||||
);
|
||||
@@ -0,0 +1,42 @@
|
||||
import {
|
||||
DialogContent,
|
||||
PdfDocumentPreview,
|
||||
FormattedMessage as T,
|
||||
} from '@/components';
|
||||
import { useVendorBalanceSummaryPdfExport } from '@/hooks/query';
|
||||
import { AnchorButton } from '@blueprintjs/core';
|
||||
|
||||
export default function VendorTransactionsPdfDialogContent() {
|
||||
const { isLoading, pdfUrl } = useVendorBalanceSummaryPdfExport();
|
||||
|
||||
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 './VendorBalancePdfDialog';
|
||||
Reference in New Issue
Block a user