mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
re-structure to monorepo.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import FinancialReportPage from '../FinancialReportPage';
|
||||
import { useCashFlowStatementReport } from '@/hooks/query';
|
||||
import { transformFilterFormToQuery } from '../common';
|
||||
|
||||
const CashFLowStatementContext = React.createContext();
|
||||
|
||||
/**
|
||||
* Cash flow statement provider.
|
||||
*/
|
||||
function CashFlowStatementProvider({ filter, ...props }) {
|
||||
// transforms the given filter to query.
|
||||
const query = React.useMemo(
|
||||
() => transformFilterFormToQuery(filter),
|
||||
[filter],
|
||||
);
|
||||
|
||||
// fetch the cash flow statement report.
|
||||
const {
|
||||
data: cashFlowStatement,
|
||||
isFetching: isCashFlowFetching,
|
||||
isLoading: isCashFlowLoading,
|
||||
refetch: refetchCashFlow,
|
||||
} = useCashFlowStatementReport(query, { keepPreviousData: true });
|
||||
|
||||
const provider = {
|
||||
cashFlowStatement,
|
||||
isCashFlowFetching,
|
||||
isCashFlowLoading,
|
||||
refetchCashFlow,
|
||||
query,
|
||||
filter,
|
||||
};
|
||||
|
||||
return (
|
||||
<FinancialReportPage name="cash-flow-statement">
|
||||
<CashFLowStatementContext.Provider value={provider} {...props} />
|
||||
</FinancialReportPage>
|
||||
);
|
||||
}
|
||||
|
||||
const useCashFlowStatementContext = () =>
|
||||
React.useContext(CashFLowStatementContext);
|
||||
|
||||
export { CashFlowStatementProvider, useCashFlowStatementContext };
|
||||
Reference in New Issue
Block a user