mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
43 lines
995 B
JavaScript
43 lines
995 B
JavaScript
import React from 'react';
|
|
import FinancialReportPage from '../FinancialReportPage';
|
|
import { useInventoryValuation } from 'hooks/query';
|
|
import { transformFilterFormToQuery } from '../common';
|
|
|
|
const InventoryValuationContext = React.createContext();
|
|
|
|
function InventoryValuationProvider({ query, ...props }) {
|
|
const {
|
|
data: inventoryValuation,
|
|
isFetching,
|
|
isLoading,
|
|
refetch,
|
|
} = useInventoryValuation(
|
|
{
|
|
...transformFilterFormToQuery(query),
|
|
},
|
|
{
|
|
keepPreviousData: true,
|
|
},
|
|
);
|
|
|
|
|
|
// Provider data.
|
|
const provider = {
|
|
inventoryValuation,
|
|
isLoading,
|
|
isFetching,
|
|
refetchSheet: refetch,
|
|
};
|
|
|
|
return (
|
|
<FinancialReportPage name={'inventory-valuation'}>
|
|
<InventoryValuationContext.Provider value={provider} {...props} />
|
|
</FinancialReportPage>
|
|
);
|
|
}
|
|
|
|
const useInventoryValuationContext = () =>
|
|
React.useContext(InventoryValuationContext);
|
|
|
|
export { InventoryValuationProvider, useInventoryValuationContext };
|