feat(warehouseTransfer): add crud warehouse transfer.

This commit is contained in:
elforjani13
2022-02-03 00:27:42 +02:00
parent a81f1e7a9c
commit 8bf64c68e0
22 changed files with 407 additions and 77 deletions

View File

@@ -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>
);