{'Print Labels'}
diff --git a/src/pages/widgetLabel/index.js b/src/pages/widgetLabel/index.js
index 3ad85b2..562afbe 100644
--- a/src/pages/widgetLabel/index.js
+++ b/src/pages/widgetLabel/index.js
@@ -1,21 +1,33 @@
-import { Box, TableBody, TableCell, TableRow } from '@mui/material';
+import { Box, Grid, TableBody, TableCell, TableRow } from '@mui/material';
import DashboardNavbar from 'components/DashboardNavbar';
import DashboardLayout from 'layouts/DashboardLayout';
import { makeStyles } from '@mui/styles';
-import OutlinedInput from '@mui/material/OutlinedInput';
-import MenuItem from '@mui/material/MenuItem';
-import Select from '@mui/material/Select';
-import React from 'react';
-import SearchBar from 'components/SearchBar';
+import React, { useState } from 'react';
import BasicTable from 'components/BasicTable';
-import Barcodeimage from 'assets/images/barcode-number.png';
import MDButton from 'components/Button';
import Checkbox from '@mui/material/Checkbox';
-
const label = { inputProps: { 'aria-label': 'Checkbox demo' } };
import Breadcrumbs from 'components/Breadcrumbs';
+import Dropdown from 'components/Dropdown';
+import { useDispatch, useSelector } from 'react-redux';
+import { InventorySelectors } from 'redux/InventoryRedux';
+import WidgetActions from 'redux/WidgetRedux';
+import { API } from 'constant';
+import MDBox from 'components/MDBox';
+import { WidgetSelectors } from 'redux/WidgetRedux';
+import ProductActions from 'redux/ProductsRedux';
+import { ProductSelectors } from 'redux/ProductsRedux';
+import InventoryActions from 'redux/InventoryRedux';
+import QRcode from 'components/QRcode';
const useStyles = makeStyles({
+ nodataStyle: {
+ height: '200px',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '600%'
+ },
labelSize: {
fontSize: '16px',
letterSpacing: '0.01em',
@@ -32,69 +44,6 @@ const useStyles = makeStyles({
margin: '52px 0px'
}
});
-const records = [
- {
- warehouse: 'Ipsum',
- zone: 'Vivera',
- area: 'Nisi',
- row: 'Nulla',
- label: 'Mauris',
- bay: 'Senectus',
- barcodenumber: '2085550112',
- barcodeimage: Barcodeimage
- },
- {
- warehouse: 'Ipsum',
- zone: 'Vivera',
- area: 'Nisi',
- row: 'Nulla',
- label: 'Mauris',
- bay: 'Senectus',
- barcodenumber: '2085550112',
- barcodeimage: Barcodeimage
- },
- {
- warehouse: 'Ipsum',
- zone: 'Vivera',
- area: 'Nisi',
- row: 'Nulla',
- label: 'Mauris',
- bay: 'Senectus',
- barcodenumber: '2085550112',
- barcodeimage: Barcodeimage
- }
-];
-
-const recordsNew = [
- {
- warehouse: 'Ipsum',
- zone: 'Vivera',
- area: 'Nisi',
- barcodenumber: '2085550112',
- barcodeimage: Barcodeimage
- },
- {
- warehouse: 'Ipsum',
- zone: 'Vivera',
- area: 'Nisi',
- barcodenumber: '2085550112',
- barcodeimage: Barcodeimage
- },
- {
- warehouse: 'Ipsum',
- zone: 'Vivera',
- area: 'Nisi',
- barcodenumber: '2085550112',
- barcodeimage: Barcodeimage
- },
- {
- warehouse: 'Ipsum',
- zone: 'Vivera',
- area: 'Nisi',
- barcodenumber: '2085550112',
- barcodeimage: Barcodeimage
- }
-];
const headCells = [
{
@@ -110,15 +59,15 @@ const headCells = [
label: 'Subfamily'
},
{
- id: 'Name',
+ id: 'formalName',
label: 'Name'
},
{
- id: 'Manufacture',
+ id: 'manufacturer',
label: 'Manufacture'
},
{
- id: 'Size',
+ id: 'size',
label: 'Size'
},
{
@@ -136,11 +85,11 @@ const headCellsNew = [
label: 'Inventory Name'
},
{
- id: 'Item Name',
+ id: 'formalName',
label: 'Item Name'
},
{
- id: 'Item Description',
+ id: 'description',
label: 'Item Description'
},
{
@@ -152,18 +101,93 @@ const headCellsNew = [
label: 'Barcode'
}
];
+
function WidgetLabel() {
const classes = useStyles();
- const [personName, setPersonName] = React.useState([]);
+ const dispatch = useDispatch();
+ const [labelData, setLabelData] = useState([]);
+ const [inventoryId, setInventoryId] = useState('');
+ const [familyId, setFamilyId] = useState('');
+ const [allProductData, setAllProductData] = useState([]);
+ const [filterClick, setFilterClick] = useState(false);
- const handleChange = (event) => {
- const {
- target: { value }
- } = event;
- setPersonName(
- // On autofill we get a stringified value.
- typeof value === 'string' ? value.split(',') : value
+ const inventoryData = useSelector(InventorySelectors.getInventoryDetail);
+ const familyData = useSelector(WidgetSelectors.getWidgetFamiliesByInventoryId(inventoryId));
+ const subFamilyData = useSelector(WidgetSelectors.getWidgetsByParentId(familyId));
+ const productData = useSelector(ProductSelectors.getProductDetail);
+
+ React.useEffect(() => {
+ dispatch(
+ InventoryActions.getInventoryAction({
+ loader: 'loading-request',
+ slug: API.GET_INVENTORY,
+ method: 'get'
+ })
);
+ }, []);
+
+ React.useEffect(() => {
+ if (productData.result && filterClick) {
+ setAllProductData(productData?.result);
+ }
+ }, [productData, filterClick]);
+
+ const inventoryChange = (event) => {
+ const filterData = inventoryData.filter((item) => item.name === event.target.value);
+ const id = filterData[0]._id;
+ setInventoryId(filterData[0]._id);
+ dispatch(
+ WidgetActions.widgetRequest({
+ loader: 'loading-request',
+ slug: `${API.GET_WIDGET_FAMILY_BY_INVENTORY}${id}`,
+ method: 'get'
+ })
+ );
+ };
+
+ const familyChange = (event) => {
+ const filterData = familyData.filter((item) => item.name === event.target.value);
+ const id = filterData[0]._id;
+ setFamilyId(filterData[0]._id);
+ dispatch(
+ WidgetActions.widgetRequest({
+ loader: 'loading-request',
+ slug: `${API.GET_WIDGET_FAMILY_BY_INVENTORY}${id}`,
+ method: 'get'
+ })
+ );
+ };
+
+ const subFamilyChange = (event) => {
+ const filterData = subFamilyData.filter((item) => item.name === event.target.value);
+ const id = filterData[0]._id;
+ dispatch(
+ WidgetActions.widgetRequest({
+ loader: 'loading-request',
+ slug: `${API.GET_WIDGET_FAMILY_BY_INVENTORY}${id}`,
+ method: 'get'
+ })
+ );
+ };
+ const filterHandler = () => {
+ setInventoryId('');
+ setFilterClick(true);
+ dispatch(
+ ProductActions.getProductByIdAction({
+ loader: 'loading-request',
+ slug: `${API.GET_PRODUCT_BY_ID}${inventoryId}`,
+ method: 'get'
+ })
+ );
+ };
+
+ const getTableItem = (e, item) => {
+ if (e.target.checked) {
+ setLabelData((prev) => [...prev, item]);
+ } else {
+ const filterData = labelData.filter((item2) => item2._id !== item._id);
+ setLabelData(filterData);
+ }
};
return (
<>
@@ -177,159 +201,93 @@ function WidgetLabel() {
{ name: 'Widget Label' }
]}
/>
-
-
-
-
- Select Inventory
-
-
- }
- renderValue={(selected) => {
- if (selected.length === 0) {
- return 'Placeholder';
- }
-
- return selected.join(', ');
- }}
- inputProps={{ 'aria-label': 'Without label' }}
- sx={{
- width: '100%'
- }}
- onChange={handleChange}
- >
-
-
-
-
-
-
-
- Select Family
-
-
- }
- renderValue={(selected) => {
- if (selected.length === 0) {
- return 'Placeholder';
- }
-
- return selected.join(', ');
- }}
- inputProps={{ 'aria-label': 'Without label' }}
- sx={{
- width: '100%'
- }}
- onChange={handleChange}
- >
-
-
-
-
-
-
-
- Select Sub Family
-
-
- }
- renderValue={(selected) => {
- if (selected.length === 0) {
- return 'Placeholder';
- }
-
- return selected.join(', ');
- }}
- inputProps={{ 'aria-label': 'Without label' }}
- sx={{
- width: '100%'
- }}
- onChange={handleChange}
- >
-
-
-
-
-
-
-
- Search Keyword
-
-
-
-
-
-
- {'Filter'}
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+ filterHandler()}
+ >
+ {'Filter'}
+
+
+
- {records &&
- records.map((item) => (
+ {filterClick && allProductData.length ? (
+ allProductData &&
+ allProductData.map((item) => (
- {item.warehouse}
- {item.zone}
- {item.area}
- {item.row}
- {item.label}
- {item.bay}
- {item.barcodenumber}
-
+ getTableItem(e, item)}
+ />
+ {item?.inventory?.name}
+
+ {item?.widgetfamily?.name}
+ {item?.location?.sub_levels}
+ {item?.formalName}
+ {item?.manufacturer}
+ {item?.size}
+ {item?._id}
+
+
- ))}
+ ))
+ ) : (
+ No Data
+ )}
- {recordsNew &&
- recordsNew.map((item) => (
+ {labelData &&
+ labelData.map((item) => (
- {item.warehouse}
- {item.zone}
- {item.area}
- {item.barcodenumber}
+ {item?.inventory?.name}
+ {item.formalName}
+ {item.description}
+ {item._id}
-
+
))}
@@ -339,7 +297,7 @@ function WidgetLabel() {
{'Print Labels'}
-
+
>
);
diff --git a/src/redux/LabellingRedux.js b/src/redux/LabellingRedux.js
new file mode 100644
index 0000000..07a45f1
--- /dev/null
+++ b/src/redux/LabellingRedux.js
@@ -0,0 +1,54 @@
+import { createActions, createReducer } from 'reduxsauce';
+import Immutable from 'seamless-immutable';
+import _ from 'underscore';
+import { getFetchingValue, getErrorValue } from '../services/Utils';
+
+/* ------------- Types and Action Creators ------------- */
+const { Types, Creators } = createActions({
+ getLabelAction: ['payload'],
+ getLabelSuccess: ['data'],
+ getLabelFailure: ['error']
+});
+
+export const LabellingTypes = Types;
+const LabellingActions = Creators;
+export default LabellingActions;
+
+/* ------------- Initial State ------------- */
+export const INITIAL_STATE = Immutable({
+ getLabelDetail: [],
+ getLabelLoading: false,
+ getLabelerror: {}
+});
+
+/* ------------- Selectors ------------- */
+export const LabellingSelectors = {
+ getLabelDetail: (state) => state.labelling.getLabelDetail
+};
+
+/* ------------- Reducers ------------- */
+export const onGetLabelAction = (state, { payload }) =>
+ state.merge({
+ fetching: _.uniq([state.fetching, payload?.loader]),
+ error: getErrorValue(state?.error, payload?.loader)
+ });
+
+export const onGetLabelSuccess = (state, { data }) =>
+ state.merge({
+ fetching: getFetchingValue(state.fetching, data?.loader),
+ error: getErrorValue(state?.error, data?.loader),
+ getLabelDetail: data.getLabelDetail
+ });
+
+export const onGetLabelFailure = (state, { error }) =>
+ state.merge({
+ fetching: _.without(state.fetching, error?.loader),
+ error: { ...state.error, [error?.loader]: error?.error }
+ });
+
+/* ------------- Hookup Reducers To Types ------------- */
+export const labellingReducer = createReducer(INITIAL_STATE, {
+ [Types.GET_LABEL_ACTION]: onGetLabelAction,
+ [Types.GET_LABEL_SUCCESS]: onGetLabelSuccess,
+ [Types.GET_LABEL_FAILURE]: onGetLabelFailure
+});
diff --git a/src/redux/ProductsRedux.js b/src/redux/ProductsRedux.js
index 29d8d88..12aeed4 100644
--- a/src/redux/ProductsRedux.js
+++ b/src/redux/ProductsRedux.js
@@ -5,6 +5,9 @@ import { getFetchingValue, getErrorValue } from '../services/Utils';
/* ------------- Types and Action Creators ------------- */
const { Types, Creators } = createActions({
+ getProductByIdAction: ['payload'],
+ getProductByIdSuccess: ['data'],
+ getProductByIdFailure: ['error'],
addProductAction: ['payload'],
addProductSuccess: ['data'],
addProductFailure: ['error']
@@ -18,15 +21,35 @@ export default ProductActions;
export const INITIAL_STATE = Immutable({
addProductDetail: [],
addProductLoading: false,
- addProducterror: {}
+ addProducterror: {},
+ getProductByIdDetail: []
});
/* ------------- Selectors ------------- */
export const ProductSelectors = {
- addProductDetail: (state) => state.product.productDetail
+ addProductDetail: (state) => state.product.productDetail,
+ getProductDetail: (state) => state.product.getProductByIdDetail
};
/* ------------- Reducers ------------- */
+export const onGetProductByIdAction = (state, { payload }) =>
+ state.merge({
+ fetching: _.uniq([state.fetching, payload?.loader]),
+ error: getErrorValue(state?.error, payload?.loader)
+ });
+
+export const onGetProductByIdSuccess = (state, { data }) =>
+ state.merge({
+ fetching: getFetchingValue(state.fetching, data?.loader),
+ error: getErrorValue(state?.error, data?.loader),
+ getProductByIdDetail: data.getProductByIdDetail
+ });
+
+export const onGetProductByIdFailure = (state, { error }) =>
+ state.merge({
+ fetching: _.without(state.fetching, error?.loader),
+ error: { ...state.error, [error?.loader]: error?.error }
+ });
export const onAddProductAction = (state, { payload }) =>
state.merge({
fetching: _.uniq([state.fetching, payload?.loader]),
@@ -48,6 +71,10 @@ export const onAddProductFailure = (state, { error }) =>
/* ------------- Hookup Reducers To Types ------------- */
export const productReducer = createReducer(INITIAL_STATE, {
+ [Types.GET_PRODUCT_BY_ID_ACTION]: onGetProductByIdAction,
+ [Types.GET_PRODUCT_BY_ID_SUCCESS]: onGetProductByIdSuccess,
+ [Types.GET_PRODUCT_BY_ID_FAILURE]: onGetProductByIdFailure,
+ [Types.ADD_PRODUCT_FAILURE]: onAddProductFailure,
[Types.ADD_PRODUCT_ACTION]: onAddProductAction,
[Types.ADD_PRODUCT_SUCCESS]: onAddProductSuccess,
[Types.ADD_PRODUCT_FAILURE]: onAddProductFailure
diff --git a/src/redux/index.js b/src/redux/index.js
index 4372ad0..fe5ce5e 100644
--- a/src/redux/index.js
+++ b/src/redux/index.js
@@ -8,6 +8,7 @@ import { rolesReducer } from './RolesRedux';
import { permissionsReducer } from './PermissionsRedux';
import { WarehouseLocationsReducer } from './WarehouseLocationsRedux';
import { widgetReducer } from './WidgetRedux';
+import { labellingReducer } from './LabellingRedux';
import { itemReducer } from './ItemRedux';
// Combine all reducers.
@@ -21,6 +22,7 @@ const appReducer = combineReducers({
product: productReducer,
inventory: inventoryReducer,
widgets: widgetReducer,
+ labelling: labellingReducer,
items: itemReducer
});
diff --git a/src/sagas/Labelling.js b/src/sagas/Labelling.js
new file mode 100644
index 0000000..51bcbcb
--- /dev/null
+++ b/src/sagas/Labelling.js
@@ -0,0 +1,31 @@
+import { AuthorizedAPI } from 'config';
+import { takeLatest, call, put } from 'redux-saga/effects';
+import LabellingActions from 'redux/LabellingRedux';
+import { LabellingTypes } from 'redux/LabellingRedux';
+import ApiServices from 'services/API/ApiServices';
+
+export function* onRequestGetLabelData({ payload }) {
+ const response = yield call(
+ ApiServices[payload?.method],
+ AuthorizedAPI,
+ payload?.slug,
+ payload?.data
+ );
+ if (response?.status === 200) {
+ yield put(
+ LabellingActions.getLabelSuccess({
+ loader: payload?.loader,
+ getLabelDetail: response?.data?.data
+ })
+ );
+ } else {
+ payload.onFailedGetLabelData(response.data.error);
+ yield put(
+ LabellingActions.getLabelFailure({
+ loader: payload?.loader,
+ error: response?.data
+ })
+ );
+ }
+}
+export default [takeLatest(LabellingTypes.GET_LABEL_ACTION, onRequestGetLabelData)];
diff --git a/src/sagas/Product.js b/src/sagas/Product.js
index 49c2c81..fad38ef 100644
--- a/src/sagas/Product.js
+++ b/src/sagas/Product.js
@@ -28,4 +28,32 @@ export function* onRequestAddProductData({ payload }) {
);
}
}
-export default [takeLatest(ProductTypes.ADD_PRODUCT_ACTION, onRequestAddProductData)];
+
+export function* onRequestGetProductById({ payload }) {
+ const response = yield call(
+ ApiServices[payload?.method],
+ AuthorizedAPI,
+ payload?.slug,
+ payload?.data
+ );
+ if (response?.status === 200) {
+ yield put(
+ ProductActions.getProductByIdSuccess({
+ loader: payload?.loader,
+ getProductByIdDetail: response?.data?.data
+ })
+ );
+ } else {
+ payload.onFailedGetProductById(response.data.error);
+ yield put(
+ ProductActions.getProductByIdFailure({
+ loader: payload?.loader,
+ error: response?.data
+ })
+ );
+ }
+}
+export default [
+ takeLatest(ProductTypes.ADD_PRODUCT_ACTION, onRequestAddProductData),
+ takeLatest(ProductTypes.GET_PRODUCT_BY_ID_ACTION, onRequestGetProductById)
+];
diff --git a/src/sagas/index.js b/src/sagas/index.js
index 263836a..8031190 100644
--- a/src/sagas/index.js
+++ b/src/sagas/index.js
@@ -8,6 +8,7 @@ import RolesSaga from './Roles';
import PermissionsSaga from './Permissions';
import WarehouseLocationsSaga from './WarehouseLocations';
import WidgetSaga from './Widget';
+import LabellingSaga from './Labelling';
import ItemSaga from './Item';
export default function* rootSaga() {
@@ -20,5 +21,6 @@ export default function* rootSaga() {
yield all([...PermissionsSaga]);
yield all([...WarehouseLocationsSaga]);
yield all([...WidgetSaga]);
+ yield all([...LabellingSaga]);
yield all([...ItemSaga]);
}