mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-22 15:50:32 +00:00
feat(warehouseTransfer): add crud warehouse transfer.
This commit is contained in:
@@ -2,22 +2,74 @@ import React from 'react';
|
||||
import { isEmpty } from 'lodash';
|
||||
|
||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||
import {
|
||||
useResourceViews,
|
||||
useResourceMeta,
|
||||
useWarehousesTransfers,
|
||||
useRefreshWarehouseTransfers,
|
||||
} from 'hooks/query';
|
||||
|
||||
import { getFieldsFromResourceMeta } from 'utils';
|
||||
|
||||
const WarehouseTransfersListContext = React.createContext();
|
||||
|
||||
/**
|
||||
* WarehouseTransfer data provider
|
||||
*/
|
||||
function WarehouseTransfersListProvider({ ...props }) {
|
||||
function WarehouseTransfersListProvider({
|
||||
query,
|
||||
tableStateChanged,
|
||||
...props
|
||||
}) {
|
||||
// warehouse transfers refresh action.
|
||||
const { refresh } = useRefreshWarehouseTransfers();
|
||||
|
||||
// Fetch warehouse transfers list according to the given custom view id.
|
||||
const {
|
||||
data: { warehousesTransfers, pagination, filterMeta },
|
||||
isFetching: isWarehouseTransfersFetching,
|
||||
isLoading: isWarehouseTransfersLoading,
|
||||
} = useWarehousesTransfers(query, { keepPreviousData: true });
|
||||
|
||||
// Detarmines the datatable empty status.
|
||||
const isEmptyStatus = false;
|
||||
const isEmptyStatus =
|
||||
isEmpty(warehousesTransfers) && !isWarehouseTransfersLoading;
|
||||
|
||||
// Fetch create notes resource views and fields.
|
||||
const { data: WarehouseTransferView, isLoading: isViewsLoading } =
|
||||
useResourceViews('warehouse_transfer');
|
||||
|
||||
// Fetch the accounts resource fields.
|
||||
const {
|
||||
data: resourceMeta,
|
||||
isLoading: isResourceLoading,
|
||||
isFetching: isResourceFetching,
|
||||
} = useResourceMeta('warehouse_transfer');
|
||||
|
||||
// Provider payload.
|
||||
const provider = {
|
||||
warehousesTransfers,
|
||||
pagination,
|
||||
|
||||
WarehouseTransferView,
|
||||
refresh,
|
||||
|
||||
resourceMeta,
|
||||
fields: getFieldsFromResourceMeta(resourceMeta.fields),
|
||||
isResourceLoading,
|
||||
isResourceFetching,
|
||||
|
||||
isWarehouseTransfersLoading,
|
||||
isWarehouseTransfersFetching,
|
||||
isViewsLoading,
|
||||
isEmptyStatus,
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardInsider name={'warehouse-transfers-list'}>
|
||||
<DashboardInsider
|
||||
loading={isViewsLoading || isResourceLoading}
|
||||
name={'warehouse-transfers-list'}
|
||||
>
|
||||
<WarehouseTransfersListContext.Provider value={provider} {...props} />
|
||||
</DashboardInsider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user