mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
* feat: inventory valuation csv and xlsx export * feat(server): inventory valuation sheet exporting * feat(webapp): inventory valuation sheet dyanmic columns * feat: inventory valuation dynamic columns * feat: inventory valuation TS types
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
// @ts-nocheck
|
|
import React from 'react';
|
|
import FinancialReportPage from '../FinancialReportPage';
|
|
import { useInventoryValuationTable } from '@/hooks/query';
|
|
import { transformFilterFormToQuery } from '../common';
|
|
|
|
const InventoryValuationContext = React.createContext();
|
|
|
|
/**
|
|
* Inventory valuation sheet provider.
|
|
*/
|
|
function InventoryValuationProvider({ query, ...props }) {
|
|
// Transformes the filter form query to request query.
|
|
const requestQuery = React.useMemo(
|
|
() => transformFilterFormToQuery(query),
|
|
[query],
|
|
);
|
|
|
|
const {
|
|
data: inventoryValuation,
|
|
isFetching,
|
|
isLoading,
|
|
refetch,
|
|
} = useInventoryValuationTable(requestQuery, {
|
|
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 };
|