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:
@@ -1,7 +1,7 @@
|
||||
// @ts-nocheck
|
||||
import React, { createContext, useContext, useMemo } from 'react';
|
||||
import FinancialReportPage from '../FinancialReportPage';
|
||||
import { createContext, useContext, useMemo } from 'react';
|
||||
import { useProfitLossSheet } from '@/hooks/query';
|
||||
import FinancialReportPage from '../FinancialReportPage';
|
||||
import { transformFilterFormToQuery } from '../common';
|
||||
|
||||
const ProfitLossSheetContext = createContext();
|
||||
@@ -11,27 +11,22 @@ const ProfitLossSheetContext = createContext();
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
function ProfitLossSheetProvider({ query, ...props }) {
|
||||
|
||||
const innerQuery = useMemo(() => {
|
||||
return transformFilterFormToQuery(query);
|
||||
}, [query]);
|
||||
const httpQuery = useMemo(() => transformFilterFormToQuery(query), [query]);
|
||||
|
||||
const {
|
||||
data: profitLossSheet,
|
||||
isFetching,
|
||||
isLoading,
|
||||
refetch,
|
||||
} = useProfitLossSheet(
|
||||
innerQuery,
|
||||
{ keepPreviousData: true },
|
||||
);
|
||||
} = useProfitLossSheet(httpQuery, { keepPreviousData: true });
|
||||
|
||||
const provider = {
|
||||
profitLossSheet,
|
||||
isLoading,
|
||||
isFetching,
|
||||
sheetRefetch: refetch,
|
||||
query: innerQuery
|
||||
query: httpQuery,
|
||||
httpQuery,
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
import {
|
||||
DialogContent,
|
||||
PdfDocumentPreview,
|
||||
@@ -5,9 +6,11 @@ import {
|
||||
} from '@/components';
|
||||
import { AnchorButton } from '@blueprintjs/core';
|
||||
import { useProfitLossSheetPdf } from '@/hooks/query';
|
||||
import { useProfitLossSheetContext } from '../ProfitLossProvider';
|
||||
|
||||
export default function ProfitLossSheetPdfDialogContent() {
|
||||
const { isLoading, pdfUrl } = useProfitLossSheetPdf();
|
||||
const { httpQuery } = useProfitLossSheetContext();
|
||||
const { isLoading, pdfUrl } = useProfitLossSheetPdf(httpQuery);
|
||||
|
||||
return (
|
||||
<DialogContent>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @ts-nocheck
|
||||
import React, { useRef } from 'react';
|
||||
import { useRef } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Classes,
|
||||
@@ -78,7 +78,7 @@ export const ProfitLossSheetExportMenu = () => {
|
||||
isCloseButtonShown: true,
|
||||
timeout: 2000,
|
||||
};
|
||||
const { query } = useProfitLossSheetContext();
|
||||
const { httpQuery } = useProfitLossSheetContext();
|
||||
|
||||
const openProgressToast = (amount: number) => {
|
||||
return (
|
||||
@@ -96,7 +96,7 @@ export const ProfitLossSheetExportMenu = () => {
|
||||
};
|
||||
|
||||
// Export the report to xlsx.
|
||||
const { mutateAsync: xlsxExport } = useProfitLossSheetXlsxExport(query, {
|
||||
const { mutateAsync: xlsxExport } = useProfitLossSheetXlsxExport(httpQuery, {
|
||||
onDownloadProgress: (xlsxExportProgress: number) => {
|
||||
if (!toastKey.current) {
|
||||
toastKey.current = AppToaster.show({
|
||||
@@ -115,7 +115,7 @@ export const ProfitLossSheetExportMenu = () => {
|
||||
},
|
||||
});
|
||||
// Export the report to csv.
|
||||
const { mutateAsync: csvExport } = useProfitLossSheetCsvExport(query, {
|
||||
const { mutateAsync: csvExport } = useProfitLossSheetCsvExport(httpQuery, {
|
||||
onDownloadProgress: (xlsxExportProgress: number) => {
|
||||
if (!toastKey.current) {
|
||||
toastKey.current = AppToaster.show({
|
||||
|
||||
Reference in New Issue
Block a user