From d9053688bf976c215163e5c64dedf83fa9444c2a Mon Sep 17 00:00:00 2001 From: bluestreamlds <85561356+bluestreamlds@users.noreply.github.com> Date: Sun, 27 Feb 2022 13:29:38 +0530 Subject: [PATCH] Fixes/overall (#64) * Update: remove autofocus * Update: Breadcrumbs functionality * Update: removed validation for attributes * Update: Field name * Update: warehouse setup breadcrumbs * Update: Inventory setup breadcrumbs Co-authored-by: Llewellyn Dsouza --- src/components/Breadcrumbs/index.js | 94 ++++++++++++------------- src/components/DashboardNavbar/index.js | 14 ++-- src/pages/addNewProduct/index.js | 10 +++ src/pages/editWarehouseDetails/index.js | 18 +++-- src/pages/homepage/index.js | 2 + src/pages/inventory/index.js | 9 +++ src/pages/newWarehouseDetails/index.js | 15 +++- src/pages/setup/index.js | 2 + src/pages/setupInventory/index.js | 23 ++++-- src/pages/warehouse/index.js | 12 +++- src/services/ValidationServices.js | 2 +- 11 files changed, 128 insertions(+), 73 deletions(-) diff --git a/src/components/Breadcrumbs/index.js b/src/components/Breadcrumbs/index.js index 7cec983..a424bc3 100644 --- a/src/components/Breadcrumbs/index.js +++ b/src/components/Breadcrumbs/index.js @@ -16,7 +16,7 @@ import { Link } from 'react-router-dom'; import PropTypes from 'prop-types'; // @mui material components -import { Breadcrumbs as MuiBreadcrumbs, Grid } from '@mui/material'; +import { Breadcrumbs as MuiBreadcrumbs, Grid, Toolbar } from '@mui/material'; import ArrowRight from 'assets/images/CarretArrowRightIcon'; // Material Dashboard 2 PRO React components @@ -24,65 +24,64 @@ import MDBox from 'components/MDBox'; import MDTypography from 'components/MDTypography'; const buildBreadcrumbs = (route, light) => { - if (route[0] === 'home') route = []; - else if (route.length === 1) route = ['home']; - else { - route = ['home', ...route]; - route.pop(); - } - return route.map((el) => ( - + return route.map((el) => { + return el.path ? ( + + + {el.name} + + + ) : ( - {el} + {el.name} - - )); + ); + }); }; -function Breadcrumbs({ title, route, light, children }) { +function Breadcrumbs({ route, light, children }) { return ( - - - - (light ? white.main : grey[600]), - padding: '0 8px' - } - }} - separator={} - > - {buildBreadcrumbs(route, light)} - + + + + (light ? white.main : grey[600]), + padding: '0 8px' + } + }} + separator={} > - {title.replace('-', ' ')} - - + {buildBreadcrumbs(route, light)} + + + + {children} + - - {children} - - - + + ); } @@ -93,7 +92,6 @@ Breadcrumbs.defaultProps = { // Typechecking props for the Breadcrumbs Breadcrumbs.propTypes = { - title: PropTypes.string.isRequired, route: PropTypes.oneOfType([PropTypes.string, PropTypes.array]).isRequired, light: PropTypes.bool, children: PropTypes.node diff --git a/src/components/DashboardNavbar/index.js b/src/components/DashboardNavbar/index.js index 301783e..7206949 100644 --- a/src/components/DashboardNavbar/index.js +++ b/src/components/DashboardNavbar/index.js @@ -17,7 +17,7 @@ import { useState, useEffect } from 'react'; // import Grid from '@mui/material/Grid'; // react-router components -import { useLocation } from 'react-router-dom'; +// import { useLocation } from 'react-router-dom'; import { useDispatch } from 'react-redux'; import AuthActions from 'redux/AuthRedux'; @@ -40,7 +40,7 @@ import MDBox from 'components/MDBox'; // import MDBadge from 'components/MDBadge'; // Material Dashboard 2 PRO React example components -import Breadcrumbs from 'components/Breadcrumbs'; +// import Breadcrumbs from 'components/Breadcrumbs'; import NotificationItem from 'components/NotificationItem'; // import InputAdornment from '@mui/material/InputAdornment'; @@ -49,7 +49,7 @@ import NotificationItem from 'components/NotificationItem'; import { // navbar, // navbarContainer, - navbarRow, + // navbarRow, navbarIconButton, // navbarDesktopMenu, navbarMobileMenu @@ -81,14 +81,14 @@ const useStyles = makeStyles(() => ({ } })); -function DashboardNavbar({ absolute, light, isMini, children }) { +function DashboardNavbar({ absolute, light, isMini /*, children*/ }) { const [navbarType, setNavbarType] = useState(); const [controller, dispatch] = useMaterialUIController(); const { miniSidenav, transparentNavbar, fixedNavbar, /*openConfigurator,*/ darkMode } = controller; // const [openMenu, setOpenMenu] = useState(false); const [openProfileMenu, setOpenProfileMenu] = useState(false); - const route = useLocation().pathname.split('/').slice(1); + // const route = useLocation().pathname.split('/').slice(1); const dispatchLogout = useDispatch(); const handleLogout = () => dispatchLogout(AuthActions.logout()); const classes = useStyles(); @@ -270,13 +270,13 @@ function DashboardNavbar({ absolute, light, isMini, children }) { )} - + {/* navbarRow(theme, { isMini })}> {children} - + */} ); } diff --git a/src/pages/addNewProduct/index.js b/src/pages/addNewProduct/index.js index 884350f..f7ec80a 100644 --- a/src/pages/addNewProduct/index.js +++ b/src/pages/addNewProduct/index.js @@ -19,6 +19,7 @@ import { useDispatch } from 'react-redux'; import ProductActions from 'redux/ProductsRedux'; import { API } from 'constant'; import LOGGER from 'services/Logger'; +import Breadcrumbs from 'components/Breadcrumbs'; const useStyles = makeStyles({ labelSize: { @@ -118,6 +119,15 @@ function AddNewProduct() { <> +
diff --git a/src/pages/editWarehouseDetails/index.js b/src/pages/editWarehouseDetails/index.js index 9eb6dfa..70c6521 100644 --- a/src/pages/editWarehouseDetails/index.js +++ b/src/pages/editWarehouseDetails/index.js @@ -24,7 +24,6 @@ import MDInput from 'components/MDInput'; 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'; @@ -36,6 +35,7 @@ import { useParams } from 'react-router-dom'; import { WarehouseLocationsSelectors } from 'redux/WarehouseLocationsRedux'; import { API } from 'constant'; import NestedDataTable from 'components/NestedTable'; +import Breadcrumbs from 'components/Breadcrumbs'; const bottomButtonStyling = { width: '100%', @@ -86,7 +86,6 @@ const AddForm = ({ addFormOpen, setAddFormOpen, selected, warehouseId }) => { {fields && fields.map((fieldName) => ( { const inventoryTypes = ['Perishable', 'Material', 'Product', 'Inventory', 'Fleet']; function EditWarehouseDetails() { - const navigate = useNavigate(); const location = useLocation(); const [open, setOpen] = useState(false); const ITEM_HEIGHT = 48; @@ -370,6 +368,14 @@ function EditWarehouseDetails() { <> + @@ -442,7 +448,7 @@ function EditWarehouseDetails() { marginBottom: '4px' }} > - Types of inventories hosted + Inventories hosted SAVE - + {/* NEXT - + */}
diff --git a/src/pages/setup/index.js b/src/pages/setup/index.js index 76e0622..8de29c1 100644 --- a/src/pages/setup/index.js +++ b/src/pages/setup/index.js @@ -5,6 +5,7 @@ import InventoryIcon from 'assets/images/InventoryIcon'; import ProfileCircleIcon from 'assets/images/ProfileCircleIcon'; import LabelIcon from 'assets/images/LabelIcon'; import TileBasic from 'components/TileBasic'; +import Breadcrumbs from 'components/Breadcrumbs'; function SetupHome() { const data = [ @@ -32,6 +33,7 @@ function SetupHome() { return ( + ); diff --git a/src/pages/setupInventory/index.js b/src/pages/setupInventory/index.js index 82b3f74..7cbac15 100644 --- a/src/pages/setupInventory/index.js +++ b/src/pages/setupInventory/index.js @@ -9,9 +9,9 @@ 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'; -function SetupInventory() -{ +function SetupInventory() { const navigate = useNavigate(); const tiles = [ @@ -43,11 +43,22 @@ function SetupInventory() ]; return ( - - navigate('/setup/inventory/inventory-new')}> - Add new Inventory + + + navigate('/setup/inventory/inventory-new')} + > + Add new Inventory - +
{tiles && diff --git a/src/pages/warehouse/index.js b/src/pages/warehouse/index.js index 33c679b..e034a9e 100644 --- a/src/pages/warehouse/index.js +++ b/src/pages/warehouse/index.js @@ -9,6 +9,7 @@ import { WarehouseSelectors } from 'redux/WarehouseRedux'; import WarehouseIcon from 'assets/images/WarehouseIcon'; import MDButton from 'components/Button'; import { useNavigate } from 'react-router-dom'; +import Breadcrumbs from 'components/Breadcrumbs'; function WarehouseScreen() { const dispatch = useDispatch(); @@ -26,7 +27,14 @@ function WarehouseScreen() { return ( - + + Add new Warehouse - + ({ ...warehouse, diff --git a/src/services/ValidationServices.js b/src/services/ValidationServices.js index 2fad8c9..58576bb 100644 --- a/src/services/ValidationServices.js +++ b/src/services/ValidationServices.js @@ -25,7 +25,7 @@ const schema = { inventorytype: Yup.array('Enter inventory Type') .of(Yup.string()) .required('inventory Type is required'), - attributes: Yup.string('Enter other attributes').required('attributes is required') + attributes: Yup.string('Enter other attributes') }), addNewProduct: Yup.object({