mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
re-structure to monorepo.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// @ts-nocheck
|
||||
import React, { createContext, useContext } from 'react';
|
||||
|
||||
import FinancialReportPage from '../FinancialReportPage';
|
||||
import { useBalanceSheet } from '@/hooks/query';
|
||||
import { transformFilterFormToQuery } from '../common';
|
||||
|
||||
const BalanceSheetContext = createContext();
|
||||
|
||||
function BalanceSheetProvider({ filter, ...props }) {
|
||||
// Transformes the given filter to query.
|
||||
const query = React.useMemo(() => transformFilterFormToQuery(filter), [
|
||||
filter,
|
||||
]);
|
||||
|
||||
// Fetches the balance sheet report.
|
||||
const {
|
||||
data: balanceSheet,
|
||||
isFetching,
|
||||
isLoading,
|
||||
refetch,
|
||||
} = useBalanceSheet(query, { keepPreviousData: true });
|
||||
|
||||
const provider = {
|
||||
balanceSheet,
|
||||
isFetching,
|
||||
isLoading,
|
||||
refetchBalanceSheet: refetch,
|
||||
|
||||
query,
|
||||
filter,
|
||||
};
|
||||
return (
|
||||
<FinancialReportPage name={'balance-sheet'}>
|
||||
<BalanceSheetContext.Provider value={provider} {...props} />
|
||||
</FinancialReportPage>
|
||||
);
|
||||
}
|
||||
|
||||
const useBalanceSheetContext = () => useContext(BalanceSheetContext);
|
||||
|
||||
export { BalanceSheetProvider, useBalanceSheetContext };
|
||||
Reference in New Issue
Block a user