From 6f99ba55410c935e5a68d66db9aba2d837185fbe Mon Sep 17 00:00:00 2001 From: "[Diksha]" <[diksha39511@gmail.com]> Date: Wed, 2 Feb 2022 14:45:41 +0530 Subject: [PATCH] warehouse api integration --- src/components/TileBasic/index.js | 51 ++++++++++---------- src/constant/Endpoints.js | 3 +- src/pages/setup/index.js | 29 ++++++----- src/pages/warehouse/index.js | 80 +++++++------------------------ src/redux/WarehouseRedux.js | 53 ++++++++++++++++++++ src/redux/index.js | 4 +- src/sagas/Warehouse.js | 31 ++++++++++++ src/sagas/index.js | 4 ++ 8 files changed, 154 insertions(+), 101 deletions(-) create mode 100644 src/redux/WarehouseRedux.js create mode 100644 src/sagas/Warehouse.js diff --git a/src/components/TileBasic/index.js b/src/components/TileBasic/index.js index 026850a..79c61fc 100644 --- a/src/components/TileBasic/index.js +++ b/src/components/TileBasic/index.js @@ -3,8 +3,14 @@ import PropTypes from 'prop-types'; import MDBox from 'components/MDBox'; import { makeStyles } from '@mui/styles'; import { Grid } from '@mui/material'; +import SetupIcon from 'assets/images/SetupIcon'; const useStyles = makeStyles({ + iconSize: { + width: '50%', + height: '50%', + marginBottom: '10px' + }, centerContent: { display: 'flex', alignItems: 'center', @@ -31,30 +37,27 @@ export default function TileBasic({ tiles }) { const classes = useStyles(); return ( <> - - - {tiles && - tiles.map((tile) => ( - <> - - white.main, - padding: '32px 40px' - }} - > - {tile.icon} - {tile.name} - - - - ))} - - + + {tiles && + tiles.map((tile) => ( + <> + + white.main, + padding: '32px 40px' + }} + > + + {tile.name} + + + + ))} + ); } diff --git a/src/constant/Endpoints.js b/src/constant/Endpoints.js index 4e526c5..26b116b 100644 --- a/src/constant/Endpoints.js +++ b/src/constant/Endpoints.js @@ -1,3 +1,4 @@ export default { - LOGIN_USER: '/user/login' + LOGIN_USER: '/user/login', + GET_WAREHOUSE_DATA: '/warehouse/all' }; diff --git a/src/pages/setup/index.js b/src/pages/setup/index.js index 9771941..96e87dd 100644 --- a/src/pages/setup/index.js +++ b/src/pages/setup/index.js @@ -7,6 +7,7 @@ import WarehouseIcon from 'assets/images/WarehouseIcon'; import InventoryIcon from 'assets/images/InventoryIcon'; import ProfileCircleIcon from 'assets/images/ProfileCircleIcon'; import LabelIcon from 'assets/images/LabelIcon'; +import { Link } from 'react-router-dom'; const useStyles = makeStyles({ iconSize: { @@ -77,19 +78,21 @@ function SetupHome() { {data.map((items) => ( <> - white.main, - padding: '32px 40px' - }} - > - {items.icon} - {items.name} - + + white.main, + padding: '32px 40px' + }} + > + {items.icon} + {items.name} + + ))} diff --git a/src/pages/warehouse/index.js b/src/pages/warehouse/index.js index 5a24340..6cac45b 100644 --- a/src/pages/warehouse/index.js +++ b/src/pages/warehouse/index.js @@ -2,76 +2,32 @@ import MDBox from 'components/MDBox'; import DashboardNavbar from 'components/DashboardNavbar'; import Footer from 'components/Footer'; import DashboardLayout from 'layouts/DashboardLayout'; -import SetupIcon from 'assets/images/SetupIcon'; import TileBasic from 'components/TileBasic'; -import { makeStyles } from '@mui/styles'; - -const useStyles = makeStyles({ - iconSize: { - width: '50%', - height: '50%', - marginBottom: '10px' - }, - margin: { - marginBottom: '20px' - } -}); +import { API } from 'constant'; +import WarehouseActions from 'redux/WarehouseRedux'; +import { useEffect } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { WarehouseSelectors } from 'redux/WarehouseRedux'; function WarehouseScreen() { - const classes = useStyles(); - const data = [ - { - name: 'Warehouse 1', - path: '/', - icon: - }, - { - name: 'Warehouse 1', - path: '/', - icon: - }, - { - name: 'Warehouse 1', - path: '/', - icon: - }, - { - name: 'Warehouse 1', - path: '/', - icon: - }, - { - name: 'Warehouse 1', - path: '/', - icon: - }, - { - name: 'Warehouse 1', - path: '/', - icon: - }, - { - name: 'Warehouse 1', - path: '/', - icon: - }, - { - name: 'Warehouse 1', - path: '/', - icon: - }, - { - name: 'Warehouse 1', - path: '/', - icon: - } - ]; + const dispatch = useDispatch(); + const warehouseData = useSelector(WarehouseSelectors.getWarehouseDetail); + + useEffect(() => { + dispatch( + WarehouseActions.warehouseDataAction({ + loader: 'loading-request', + slug: API.GET_WAREHOUSE_DATA, + method: 'get' + }) + ); + }, []); return ( - +