Fixes/ll inventory (#69)

* inventory data changes
* update Inventory changes
* Fixed: removed unnecessary imports
* Disabled: cycle count
* Added: Inventory types sagas
* Fix: null check
* Updated: policies
* Fixed: formik values
* update: allow single image
* Update: Policies control
* Updated: new inventory add form
* Update: new inventory conditional render
* Update: populate formik fields
* Added: Validation
* Added: edit functionality, disabled fields
* Update: housekeeping
* Fix: iconslug and key
* Update: route handling
* Added: endpoints
* Added: widget nested page
* Added: sagas
* Added: redux handling
* Update: new product page functionality
* Added: inventory page functionality
* Fixed: form validation
* Fix: route handling

Co-authored-by: evdigitech <evdigitech@gmail.com>
Co-authored-by: Llewellyn Dsouza <lledsouza2209@gmail.com>
This commit is contained in:
bluestreamlds
2022-03-01 03:18:16 +05:30
committed by GitHub
parent b3d7b0344a
commit af28c0b99c
15 changed files with 1151 additions and 515 deletions

View File

@@ -5,42 +5,53 @@ import EquipmentIcon from 'assets/images/EquimpmentIcon';
import ProductsIcon from 'assets/images/ProductsIcon';
import FleetIcon from 'assets/images/FleetIcon';
import RawMaterialIcon from 'assets/images/RawMaterialIcon';
import InventoryActions from 'redux/InventoryRedux';
import { InventorySelectors } from 'redux/InventoryRedux';
import { Grid } from '@mui/material';
import Tile from 'components/TileComponent';
import MDButton from 'components/Button';
import { useNavigate } from 'react-router-dom';
import Breadcrumbs from 'components/Breadcrumbs';
import { useDispatch, useSelector } from 'react-redux';
import { useEffect, useState } from 'react';
import { API } from 'constant';
function getIconFromSlug(slug) {
switch (slug) {
case 'equipment':
return <EquipmentIcon />;
case 'product':
return <ProductsIcon />;
case 'fleet':
return <FleetIcon />;
case 'rawmaterial':
default:
return <RawMaterialIcon />;
}
}
function SetupInventory() {
const navigate = useNavigate();
const dispatch = useDispatch();
const inventoryData = useSelector(InventorySelectors.getInventoryDetail);
const [inventoryAllData, setInventoryAllData] = useState([]);
const tiles = [
{
name: 'Raw Material',
path: { update: '/', addNew: '/', cycleCount: '/', list: '/' },
icon: <RawMaterialIcon />
},
{
name: 'Products',
path: {
update: '/',
addNew: '/setup/inventory/product/add-new-product',
cycleCount: '/',
list: '/'
},
icon: <ProductsIcon />
},
{
name: 'Equipment',
path: { update: '/', addNew: '/', cycleCount: '/', list: '/' },
icon: <EquipmentIcon />
},
{
name: 'Fleet',
path: { update: '/', addNew: '/', cycleCount: '/', list: '/' },
icon: <FleetIcon />
useEffect(() => {
if (inventoryData?.length) {
setInventoryAllData(inventoryData);
}
];
}, [inventoryData]);
useEffect(() => {
dispatch(
InventoryActions.getInventoryAction({
loader: 'loading-request',
slug: API.GET_INVENTORY,
method: 'get'
})
);
}, []);
return (
<DashboardLayout>
<DashboardNavbar />
@@ -51,20 +62,18 @@ function SetupInventory() {
{ name: 'Inventory' }
]}
>
<MDButton
sx={{ ml: 3 }}
color="primary"
onClick={() => navigate('/setup/inventory/inventory-new')}
>
<MDButton sx={{ ml: 3 }} color="primary" onClick={() => navigate('/setup/inventory/new')}>
Create Inventory
</MDButton>
</Breadcrumbs>
<MDBox px={2} py={3}>
<Grid container spacing={2}>
{tiles &&
tiles.map((tile) => (
<Grid item xs={12} sm={6} md={tiles.length > 4 ? 4 : 6} key={tile.name}>
<Tile data={{ name: tile.name, path: tile.path }}>{tile.icon}</Tile>
{inventoryAllData &&
inventoryAllData.map((tile) => (
<Grid item xs={12} sm={6} md={inventoryAllData?.length > 4 ? 4 : 6} key={tile._id}>
<Tile data={{ name: tile?.name, widgetname: tile?.widgetName, id: tile?._id }}>
{getIconFromSlug(tile.icon_slug)}
</Tile>
</Grid>
))}
</Grid>