diff --git a/src/App.js b/src/App.js index 81042bc..0401996 100644 --- a/src/App.js +++ b/src/App.js @@ -23,14 +23,14 @@ import LoginScreen from 'pages/authentication'; // @mui material components import { ThemeProvider } from '@mui/material/styles'; import CssBaseline from '@mui/material/CssBaseline'; -import Icon from '@mui/material/Icon'; +// import Icon from '@mui/material/Icon'; // Material Dashboard 2 PRO React components -import MDBox from 'components/MDBox'; +// import MDBox from 'components/MDBox'; // Material Dashboard 2 PRO React example components import Sidenav from 'components/Sidenav'; -import Configurator from 'components/Configurator'; +// import Configurator from 'components/Configurator'; // Material Dashboard 2 PRO React themes import theme from 'assets/theme'; @@ -39,7 +39,7 @@ import theme from 'assets/theme'; import themeDark from 'assets/theme-dark'; // Material Dashboard 2 PRO React contexts -import { useMaterialUIController, setMiniSidenav, setOpenConfigurator } from 'context'; +import { useMaterialUIController, setMiniSidenav /*, setOpenConfigurator*/ } from 'context'; // Images // import brandWhite from 'assets/images/logo-ct.png'; @@ -59,7 +59,7 @@ export default function App() { miniSidenav, direction, layout, - openConfigurator, + // openConfigurator, sidenavColor, // transparentSidenav, // whiteSidenav, @@ -85,7 +85,7 @@ export default function App() { }; // Change the openConfigurator state - const handleConfiguratorOpen = () => setOpenConfigurator(dispatch, !openConfigurator); + // const handleConfiguratorOpen = () => setOpenConfigurator(dispatch, !openConfigurator); // Setting the dir attribute for the body element useEffect(() => { @@ -116,29 +116,29 @@ export default function App() { return null; }); - const configsButton = ( - - - settings - - - ); + // const configsButton = ( + // + // + // settings + // + // + // ); return ( @@ -155,11 +155,11 @@ export default function App() { onMouseEnter={handleOnMouseEnter} onMouseLeave={handleOnMouseLeave} /> - - {configsButton} + {/* */} + {/* {configsButton} */} )} - {layout === 'vr' && } + {/* {layout === 'vr' && } */} } />} /> {getRoutes(routes)} diff --git a/src/pages/editWarehouseDetails/index.js b/src/pages/editWarehouseDetails/index.js index 427daca..9eb6dfa 100644 --- a/src/pages/editWarehouseDetails/index.js +++ b/src/pages/editWarehouseDetails/index.js @@ -1,7 +1,19 @@ import React, { useState } from 'react'; -import { useDispatch } from 'react-redux'; -import { Box, Grid, MenuItem, OutlinedInput, Chip, Select } from '@mui/material'; -import { makeStyles } from '@mui/styles'; +import PropTypes from 'prop-types'; +import { useDispatch, useSelector } from 'react-redux'; +import { + Box, + Grid, + MenuItem, + OutlinedInput, + Chip, + Select, + Dialog, + DialogTitle, + DialogContent, + TextField, + DialogActions +} from '@mui/material'; import DashboardNavbar from 'components/DashboardNavbar'; import DashboardLayout from 'layouts/DashboardLayout'; import ImageUpload from 'components/ImageUpload'; @@ -13,21 +25,300 @@ import { useLocation } from 'react-router-dom'; import WarehouseActions from 'redux/WarehouseRedux'; import SnackBar from 'components/SnackBar'; import { useNavigate } from 'react-router-dom'; +import { getChildLocationType } from 'utils/nestedTableTools'; +import { getPropertiesOfLocationType } from 'utils/nestedTableTools'; +import { getInitialvaluesFromParentData } from 'utils/nestedTableTools'; +import LOGGER from 'services/Logger'; +import WarehouseLocationsActions from 'redux/WarehouseLocationsRedux'; +import { getAPIslugOfLocationType } from 'utils/nestedTableTools'; +import { toTitleCase } from 'utils/nestedTableTools'; +import { useParams } from 'react-router-dom'; +import { WarehouseLocationsSelectors } from 'redux/WarehouseLocationsRedux'; +import { API } from 'constant'; +import NestedDataTable from 'components/NestedTable'; -const useStyles = makeStyles({ - labelSize: { - fontSize: '16px', - letterSpacing: '0.01em', - color: '#000', - marginBottom: '4px' - } -}); +const bottomButtonStyling = { + width: '100%', + textTransform: 'uppercase', + borderRadius: '100px', + padding: '13px 30px' +}; + +const AddForm = ({ addFormOpen, setAddFormOpen, selected, warehouseId }) => { + const dispatch = useDispatch(); + const data = addFormOpen !== 'zone' ? selected : { location: 'warehouse', id: warehouseId }; + + const childLocationType = getChildLocationType(data.location); + const fields = getPropertiesOfLocationType(childLocationType); + + const formik = useFormik({ + initialValues: getInitialvaluesFromParentData(data), + onSubmit: (values) => { + LOGGER.log('Form values and parent info', values, data); + const formData = { ...values }; + formData[`${data.location}_id`] = data.id; + dispatch( + WarehouseLocationsActions.addLocationRequest({ + loader: 'location-request', + slug: getAPIslugOfLocationType(childLocationType), + method: 'post', + data: formData, + parent: { + id: data.id, + type: data.location + } + }) + ); + setAddFormOpen(false); + } + }); + + return ( + { + setAddFormOpen(false); + }} + > + Add new {childLocationType} details + + {/* Some more text if needed */} + {fields && + fields.map((fieldName) => ( + + ))} + {childLocationType === 'sublevel' ? ( + <> + Type:{' '} + + Positions:{' '} + + + ) : null} + + + { + setAddFormOpen(false); + }} + > + Cancel + + Save + + + ); +}; + +AddForm.propTypes = { + addFormOpen: PropTypes.any, + setAddFormOpen: PropTypes.any, + selected: PropTypes.any, + warehouseId: PropTypes.any +}; + +const WarehouseNestedDetails = () => { + const [selected, setSelected] = React.useState(null); + const [addFormOpen, setAddFormOpen] = React.useState(false); + const dispatch = useDispatch(); + + const { warehouseId } = useParams(); + LOGGER.log('warehouseID', warehouseId); + const data = useSelector(WarehouseLocationsSelectors.getChildrenOfParent(warehouseId)); + + const populateChildren = (id, type) => { + LOGGER.log('populating:', id, type); + dispatch( + WarehouseLocationsActions.locationRequest({ + loader: 'location-request', + slug: API.GET_CHILDREN_FROM_PARENT, + method: 'post', + data: { id, type } + }) + ); + }; + + React.useEffect(() => { + populateChildren(warehouseId, 'warehouse'); + }, []); + + return ( + <> + + {data && + data.map((data) => ( + + ))} + {/* Debugging */} + {/*
{JSON.stringify(selected, null, 4)}
*/} + {/* Bottom buttons */} + + { + setAddFormOpen('zone'); + }} + > + Add zone + + { + setAddFormOpen(true); + }} + > + Add area + + { + setAddFormOpen(true); + }} + > + Add row + + { + setAddFormOpen(true); + }} + > + Add bay + + { + setAddFormOpen(true); + }} + > + Add Level + + { + setAddFormOpen(true); + }} + > + Add Sublevel + + +
+ {addFormOpen && ( + + )} + + ); +}; const inventoryTypes = ['Perishable', 'Material', 'Product', 'Inventory', 'Fleet']; function EditWarehouseDetails() { const navigate = useNavigate(); - const classes = useStyles(); const location = useLocation(); const [open, setOpen] = useState(false); const ITEM_HEIGHT = 48; @@ -96,7 +387,15 @@ function EditWarehouseDetails() { - + Warehouse name - + Address - + Types of inventories hosted