diff --git a/package-lock.json b/package-lock.json
index 3c91622..272e510 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -19,6 +19,7 @@
"@testing-library/user-event": "^13.5.0",
"@uiball/loaders": "^1.3.0",
"axios": "^1.4.0",
+ "dotenv": "^16.4.5",
"jwt-decode": "^3.1.2",
"react": "^18.2.0",
"react-apexcharts": "^1.4.1",
@@ -4192,6 +4193,95 @@
"url": "https://github.com/sponsors/gregberge"
}
},
+ "node_modules/@testing-library/dom": {
+ "version": "10.4.0",
+ "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.0.tgz",
+ "integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==",
+ "peer": true,
+ "dependencies": {
+ "@babel/code-frame": "^7.10.4",
+ "@babel/runtime": "^7.12.5",
+ "@types/aria-query": "^5.0.1",
+ "aria-query": "5.3.0",
+ "chalk": "^4.1.0",
+ "dom-accessibility-api": "^0.5.9",
+ "lz-string": "^1.5.0",
+ "pretty-format": "^27.0.2"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@testing-library/dom/node_modules/ansi-styles": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
+ "peer": true,
+ "dependencies": {
+ "color-convert": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"
+ }
+ },
+ "node_modules/@testing-library/dom/node_modules/chalk": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
+ "peer": true,
+ "dependencies": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/chalk?sponsor=1"
+ }
+ },
+ "node_modules/@testing-library/dom/node_modules/color-convert": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "peer": true,
+ "dependencies": {
+ "color-name": "~1.1.4"
+ },
+ "engines": {
+ "node": ">=7.0.0"
+ }
+ },
+ "node_modules/@testing-library/dom/node_modules/color-name": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+ "peer": true
+ },
+ "node_modules/@testing-library/dom/node_modules/has-flag": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+ "peer": true,
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/@testing-library/dom/node_modules/supports-color": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+ "peer": true,
+ "dependencies": {
+ "has-flag": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/@testing-library/jest-dom": {
"version": "5.16.5",
"resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.16.5.tgz",
@@ -5357,6 +5447,12 @@
"resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz",
"integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ=="
},
+ "node_modules/@yr/monotone-cubic-spline": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/@yr/monotone-cubic-spline/-/monotone-cubic-spline-1.0.3.tgz",
+ "integrity": "sha512-FQXkOta0XBSUPHndIKON2Y9JeQz5ZeMqLYZVVK93FliNBFm7LNMIZmY6FrMEB9XPcDbE2bekMbZD6kzDkxwYjA==",
+ "peer": true
+ },
"node_modules/abab": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz",
@@ -5580,6 +5676,21 @@
"node": ">= 8"
}
},
+ "node_modules/apexcharts": {
+ "version": "3.51.0",
+ "resolved": "https://registry.npmjs.org/apexcharts/-/apexcharts-3.51.0.tgz",
+ "integrity": "sha512-WpCdVdGiJjf9SAyEeg2rl3q5OqCcNqiEmH0+filMraUiH6Vqyn5GFeMMyH0pon44xjNr1G0xzIRERKRmsGEuRA==",
+ "peer": true,
+ "dependencies": {
+ "@yr/monotone-cubic-spline": "^1.0.3",
+ "svg.draggable.js": "^2.2.2",
+ "svg.easing.js": "^2.0.0",
+ "svg.filter.js": "^2.0.2",
+ "svg.pathmorphing.js": "^0.1.3",
+ "svg.resize.js": "^1.4.3",
+ "svg.select.js": "^3.0.1"
+ }
+ },
"node_modules/arg": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz",
@@ -5594,9 +5705,9 @@
}
},
"node_modules/aria-query": {
- "version": "5.2.1",
- "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.2.1.tgz",
- "integrity": "sha512-7uFg4b+lETFgdaJyETnILsXgnnzVnkHcgRbwbPwevm5x/LmUlt3MjczMRe1zg824iBgXZNRPTBftNYyRSKLp2g==",
+ "version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz",
+ "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",
"dependencies": {
"dequal": "^2.0.3"
}
@@ -7526,11 +7637,14 @@
}
},
"node_modules/dotenv": {
- "version": "10.0.0",
- "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
- "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==",
+ "version": "16.4.5",
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
+ "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
"engines": {
- "node": ">=10"
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://dotenvx.com"
}
},
"node_modules/dotenv-expand": {
@@ -15302,6 +15416,14 @@
}
}
},
+ "node_modules/react-scripts/node_modules/dotenv": {
+ "version": "10.0.0",
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
+ "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==",
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/react-scroll": {
"version": "1.8.9",
"resolved": "https://registry.npmjs.org/react-scroll/-/react-scroll-1.8.9.tgz",
@@ -16636,6 +16758,97 @@
"resolved": "https://registry.npmjs.org/svg-parser/-/svg-parser-2.0.4.tgz",
"integrity": "sha512-e4hG1hRwoOdRb37cIMSgzNsxyzKfayW6VOflrwvR+/bzrkyxY/31WkbgnQpgtrNp1SdpJvpUAGTa/ZoiPNDuRQ=="
},
+ "node_modules/svg.draggable.js": {
+ "version": "2.2.2",
+ "resolved": "https://registry.npmjs.org/svg.draggable.js/-/svg.draggable.js-2.2.2.tgz",
+ "integrity": "sha512-JzNHBc2fLQMzYCZ90KZHN2ohXL0BQJGQimK1kGk6AvSeibuKcIdDX9Kr0dT9+UJ5O8nYA0RB839Lhvk4CY4MZw==",
+ "peer": true,
+ "dependencies": {
+ "svg.js": "^2.0.1"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/svg.easing.js": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/svg.easing.js/-/svg.easing.js-2.0.0.tgz",
+ "integrity": "sha512-//ctPdJMGy22YoYGV+3HEfHbm6/69LJUTAqI2/5qBvaNHZ9uUFVC82B0Pl299HzgH13rKrBgi4+XyXXyVWWthA==",
+ "peer": true,
+ "dependencies": {
+ "svg.js": ">=2.3.x"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/svg.filter.js": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/svg.filter.js/-/svg.filter.js-2.0.2.tgz",
+ "integrity": "sha512-xkGBwU+dKBzqg5PtilaTb0EYPqPfJ9Q6saVldX+5vCRy31P6TlRCP3U9NxH3HEufkKkpNgdTLBJnmhDHeTqAkw==",
+ "peer": true,
+ "dependencies": {
+ "svg.js": "^2.2.5"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/svg.js": {
+ "version": "2.7.1",
+ "resolved": "https://registry.npmjs.org/svg.js/-/svg.js-2.7.1.tgz",
+ "integrity": "sha512-ycbxpizEQktk3FYvn/8BH+6/EuWXg7ZpQREJvgacqn46gIddG24tNNe4Son6omdXCnSOaApnpZw6MPCBA1dODA==",
+ "peer": true
+ },
+ "node_modules/svg.pathmorphing.js": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/svg.pathmorphing.js/-/svg.pathmorphing.js-0.1.3.tgz",
+ "integrity": "sha512-49HWI9X4XQR/JG1qXkSDV8xViuTLIWm/B/7YuQELV5KMOPtXjiwH4XPJvr/ghEDibmLQ9Oc22dpWpG0vUDDNww==",
+ "peer": true,
+ "dependencies": {
+ "svg.js": "^2.4.0"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/svg.resize.js": {
+ "version": "1.4.3",
+ "resolved": "https://registry.npmjs.org/svg.resize.js/-/svg.resize.js-1.4.3.tgz",
+ "integrity": "sha512-9k5sXJuPKp+mVzXNvxz7U0uC9oVMQrrf7cFsETznzUDDm0x8+77dtZkWdMfRlmbkEEYvUn9btKuZ3n41oNA+uw==",
+ "peer": true,
+ "dependencies": {
+ "svg.js": "^2.6.5",
+ "svg.select.js": "^2.1.2"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/svg.resize.js/node_modules/svg.select.js": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/svg.select.js/-/svg.select.js-2.1.2.tgz",
+ "integrity": "sha512-tH6ABEyJsAOVAhwcCjF8mw4crjXSI1aa7j2VQR8ZuJ37H2MBUbyeqYr5nEO7sSN3cy9AR9DUwNg0t/962HlDbQ==",
+ "peer": true,
+ "dependencies": {
+ "svg.js": "^2.2.5"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/svg.select.js": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/svg.select.js/-/svg.select.js-3.0.1.tgz",
+ "integrity": "sha512-h5IS/hKkuVCbKSieR9uQCj9w+zLHoPh+ce19bBYyqF53g6mnPB8sAtIbe1s9dh2S2fCmYX2xel1Ln3PJBbK4kw==",
+ "peer": true,
+ "dependencies": {
+ "svg.js": "^2.6.5"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
"node_modules/svgo": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/svgo/-/svgo-1.3.2.tgz",
@@ -17111,6 +17324,19 @@
"is-typedarray": "^1.0.0"
}
},
+ "node_modules/typescript": {
+ "version": "4.9.5",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
+ "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
+ "peer": true,
+ "bin": {
+ "tsc": "bin/tsc",
+ "tsserver": "bin/tsserver"
+ },
+ "engines": {
+ "node": ">=4.2.0"
+ }
+ },
"node_modules/unbox-primitive": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
diff --git a/package.json b/package.json
index bd9871c..6d01759 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,7 @@
"@testing-library/user-event": "^13.5.0",
"@uiball/loaders": "^1.3.0",
"axios": "^1.4.0",
+ "dotenv": "^16.4.5",
"jwt-decode": "^3.1.2",
"react": "^18.2.0",
"react-apexcharts": "^1.4.1",
diff --git a/src/App.jsx b/src/App.jsx
index f4422c6..a9e238f 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -28,6 +28,9 @@ const App = () => {
dispatch(isTokenValid());
+ // <------Fixed the 39th bug ---->
+
+ dispatch(getProducts());
}, [dispatch]);
return (
diff --git a/src/components/AlertDialogSlide.jsx b/src/components/AlertDialogSlide.jsx
index 8a12e5b..a4ba7d3 100644
--- a/src/components/AlertDialogSlide.jsx
+++ b/src/components/AlertDialogSlide.jsx
@@ -2,7 +2,9 @@ import React from "react";
import { Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, Slide } from "@mui/material";
import { GreenButton, RedButton } from "../utils/buttonStyles";
-const AlertDialogSlide = ({ dialog, showDialog, setShowDialog }) => {
+ //<-----14TH BUG FIXED ---->
+ // receiving taskHandeler as prop
+const AlertDialogSlide = ({ dialog, showDialog, setShowDialog,taskHandler }) => {
const handleClose = () => {
setShowDialog(false);
};
diff --git a/src/components/Popup.jsx b/src/components/Popup.jsx
index 8665751..7db9ca4 100644
--- a/src/components/Popup.jsx
+++ b/src/components/Popup.jsx
@@ -1,6 +1,9 @@
import * as React from 'react';
import { useDispatch } from 'react-redux';
-import { underControl } from '../redux/userHandle';
+
+ //<-------13TH BUG FIXED -------->
+ /// FIXED THE IMPORT STATEMENT OF UNDERCONTROL
+import { underControl } from '../redux/userSlice';
import MuiAlert from '@mui/material/Alert';
import { Snackbar } from '@mui/material';
diff --git a/src/components/Products.jsx b/src/components/Products.jsx
index dba78bc..fcef355 100644
--- a/src/components/Products.jsx
+++ b/src/components/Products.jsx
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useState ,useEffect} from 'react';
import { Container, Grid, Pagination } from '@mui/material';
import styled from 'styled-components';
import { useDispatch, useSelector } from 'react-redux';
@@ -8,19 +8,35 @@ import { useNavigate } from 'react-router-dom';
import Popup from './Popup';
import { addStuff } from '../redux/userHandle';
-const Products = ({}) => {
+const Products = ({ productData }) => {
const dispatch = useDispatch();
+ //<------15TH BUG --------->
+ // USING useNavigate hook
+ const navigate = useNavigate();
- const itemsPerPage = 9;
+ const itemsPerPage = 5;
+ // <----------FIXED THE 41TH BUG ----------->
+ // using useeffect to rerender the products page logic when the page is changed
- const { currentRole, responseSearch } = useSelector();
+ const { currentRole} = useSelector(state => state.user);
const [currentPage, setCurrentPage] = useState(1);
const [showPopup, setShowPopup] = useState(false);
const [message, setMessage] = useState("");
+ const [currentItems, setCurrentItems] = useState([]);
+
+// <--------FIXED THE 40TH BUG ------>
+// FIXED THE LOGIC TO CALCULATE PAGING AND SLICING PRODUCTS
+ // const indexOfLastItem = currentPage * itemsPerPage;
+ // const indexOfFirstItem = indexOfLastItem - itemsPerPage;
+ // const currentItems = productData.slice(indexOfFirstItem, indexOfLastItem);
+
+
+ useEffect(() => {
+ const indexOfLastItem = currentPage * itemsPerPage;
+ const indexOfFirstItem = indexOfLastItem - itemsPerPage;
+ setCurrentItems(productData.slice(indexOfFirstItem, indexOfLastItem));
+ }, [currentPage, productData]);
- const indexOfLastItem = currentPage * itemsPerPage;
- const indexOfFirstItem = indexOfLastItem + itemsPerPage;
- const currentItems = (indexOfFirstItem, indexOfLastItem);
const handleAddToCart = (event, product) => {
event.stopPropagation();
@@ -35,11 +51,16 @@ const Products = ({}) => {
const messageHandler = (event) => {
event.stopPropagation();
- setMessage("You have to login or register first")
+ setMessage("You have to login or register first");
setShowPopup(true)
};
- if (!responseSearch) {
+
+
+
+ {/* <------16TH BUG FIXED --------------> */}
+ {/* REPLACE responseSearch from productData */}
+ if (!productData || productData.length === 0) {
return
Product not found
;
}
@@ -85,9 +106,12 @@ const Products = ({}) => {
+
+
setCurrentPage(value)}
color="secondary"
/>
diff --git a/src/components/SpeedDialTemplate.jsx b/src/components/SpeedDialTemplate.jsx
index fb93bad..2e2eacd 100644
--- a/src/components/SpeedDialTemplate.jsx
+++ b/src/components/SpeedDialTemplate.jsx
@@ -1,5 +1,7 @@
import React from 'react'
-import { SpeedDial, styled } from '@mui/material';
+//<-------17th bug fixed ------>
+// importing SpeedDialAction from @mui/material
+import { SpeedDial,SpeedDialAction, styled } from '@mui/material';
import TuneIcon from '@mui/icons-material/Tune';
const SpeedDialTemplate = ({ actions }) => {
diff --git a/src/components/TableTemplate.jsx b/src/components/TableTemplate.jsx
index bf8ff1e..9c31f98 100644
--- a/src/components/TableTemplate.jsx
+++ b/src/components/TableTemplate.jsx
@@ -1,7 +1,11 @@
import React, {useState} from 'react'
-import {Table, TableBody, TableCell, TableContainer, TableRow, styled} from '@mui/material';
-
-const TableTemplate = ({columns, rows}) => {
+//<----------fixed 21st bug ------------->
+// import tableCellClasses from @mui/material
+import {Table, TableBody, TableCell, TableContainer, TableRow,tableCellClasses, styled} from '@mui/material';
+
+//<----FIXED 19TH BUG ---->
+ //takin buttonHaver as prop
+const TableTemplate = ({buttonHaver,columns, rows}) => {
const [page, setPage] = useState(0);
const [rowsPerPage, setRowsPerPage] = useState(5);
return (
@@ -33,14 +37,16 @@ const TableTemplate = ({columns, rows}) => {
{
column.format && typeof value === 'number'
- ? column.format(id)
+ ? column.format(value) // 18TH BUG FIXED (REPLACE id-->value)
: value
}
);
})}
+
-
+ {/* <------------FIXED 20TH BUG -------->*/}
+
);
diff --git a/src/pages/AuthenticationPage.jsx b/src/pages/AuthenticationPage.jsx
index 34a2920..657a207 100644
--- a/src/pages/AuthenticationPage.jsx
+++ b/src/pages/AuthenticationPage.jsx
@@ -10,8 +10,9 @@ import styled from 'styled-components';
import Popup from '../components/Popup';
const AuthenticationPage = ({ mode, role }) => {
-
- const bgpic = "https://images.pexels.com/photos/1121097/pexels-photo-1121097.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"
+ //<--------fixed the 38th bug------->
+ // bgpic ----->bgPic
+ const bgPic = "https://images.pexels.com/photos/1121097/pexels-photo-1121097.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"
const dispatch = useDispatch()
const navigate = useNavigate()
@@ -30,7 +31,14 @@ const AuthenticationPage = ({ mode, role }) => {
const handleSubmit = (event) => {
- let email, password;
+ //<---------46th bug fixed -------->
+ // Prevents the default form submission behavior
+ event.preventDefault();
+
+ // <---------FIXED 47TH BUG ------>
+ // let email, password; --->FIXED
+ const email = event.target.email.value;
+ const password = event.target.password.value;
if (!password) {
if (!email) setEmailError(true);
@@ -247,7 +255,7 @@ const AuthenticationPage = ({ mode, role }) => {
sm={4}
md={7}
sx={{
- backgroundImage: `url(${bgpic})`,
+ backgroundImage: `url(${bgPic})`,
backgroundRepeat: 'no-repeat',
backgroundColor: (t) =>
t.palette.mode === 'light' ? t.palette.grey[50] : t.palette.grey[900],
diff --git a/src/pages/Logout.jsx b/src/pages/Logout.jsx
index 80d0992..ba20284 100644
--- a/src/pages/Logout.jsx
+++ b/src/pages/Logout.jsx
@@ -16,11 +16,11 @@ const Logout = () => {
console.log(currentUser);
dispatch(updateCustomer(currentUser));
}
- }, [currentRole, currentUser, dispatch])
+ }, [currentRole, currentUser, dispatch]);
const handleLogout = () => {
-
- navigate('/');
+ dispatch(authLogout()); // Bug 54: Dispatch the logout action
+ navigate('/'); // Redirect to home after logout
};
const handleCancel = () => {
@@ -29,7 +29,7 @@ const Logout = () => {
return (
- {currentUser.name}
+ {currentUser?.name}
{/* Bug 54: Added optional chaining */}
Are you sure you want to log out?
Log Out
Cancel
diff --git a/src/pages/Navbar.jsx b/src/pages/Navbar.jsx
index e92613c..a4ceb96 100644
--- a/src/pages/Navbar.jsx
+++ b/src/pages/Navbar.jsx
@@ -32,33 +32,39 @@ const Navbar = () => {
const navigate = useNavigate()
const dispatch = useDispatch();
-
+ // <-----fixed the 36th bug ---->
+ // positioning of use state
+ const [anchorElNav, setAnchorElNav] = React.useState(null);
+ const [anchorElUser, setAnchorElUser] = React.useState(null);
+ const [anchorElSign, setAnchorElSign] = React.useState(null);
React.useEffect(() => {
if (currentRole === "Customer") {
console.log(currentUser);
dispatch(updateCustomer(currentUser, currentUser._id));
}
- }, [currentRole, currentUser, dispatch, ancorElNav])
+ }, [currentRole, currentUser, dispatch, anchorElNav]) //<---Fixed 22nd bug(typo)
- const [anchorElNav, setAnchorElNav] = React.useState(null);
- const [anchorElUser, setAnchorElUser] = React.useState(null);
- const [anchorElSign, setAnchorElSign] = React.useState(null);
const open = Boolean(anchorElUser);
const openSign = Boolean(anchorElSign);
const [isCartOpen, setIsCartOpen] = React.useState(false);
+
+ // FIRST BUG
+ //---> FIXED THE SYNTEX ERROR FOR OPENING THE CART AND CLOSING THE CART <----
- // Cart
- const handleOpen Cart = () => {
+ // Cart OPEN
+ const handleOpenCart = () => {
setIsCartOpen(true);
};
-
- const handleOpenCart = () => {
+
+ // SECOND BUG (FUNCTION NAME WAS OF THE SAME NAME AS ABOVE CAUSING FUNCTION OVERRIDING)
+
+ const handleCloseCart = () => {
setIsCartOpen(false);
};
- // Navigation Menu
+
const handleOpenNavMenu = (event) => {
setAnchorElNav(event.currentTarget);
};
@@ -67,7 +73,7 @@ const Navbar = () => {
setAnchorElNav(null);
};
- // User Menu
+
const handleOpenUserMenu = (event) => {
setAnchorElUser(event.currentTarget);
};
@@ -76,7 +82,7 @@ const Navbar = () => {
setAnchorElUser(null);
};
- // Signin Menu
+
const handleOpenSigninMenu = (event) => {
setAnchorElSign(event.currentTarget);
};
diff --git a/src/pages/Slide.jsx b/src/pages/Slide.jsx
index 500ce9e..ead8197 100644
--- a/src/pages/Slide.jsx
+++ b/src/pages/Slide.jsx
@@ -1,6 +1,10 @@
import { Divider, Box, Typography, Button, styled, Container } from '@mui/material';
+ // THIRD BUG
+// PREVIOUSLY IMPORT WAS FROM REACT ROUTER
+// NOW FIXED IT TO REACT ROUTER DOM
+
+import { Link, useNavigate } from 'react-router-dom';
-import { Link, useNavigate } from 'react-router';
import Carousel from 'react-multi-carousel';
import "react-multi-carousel/lib/styles.css";
diff --git a/src/pages/customer/components/Cart.jsx b/src/pages/customer/components/Cart.jsx
index c086b18..3678755 100644
--- a/src/pages/customer/components/Cart.jsx
+++ b/src/pages/customer/components/Cart.jsx
@@ -6,9 +6,18 @@ import emptyCart from "../../../assets/cartimg.png"
import KeyboardDoubleArrowLeftIcon from '@mui/icons-material/KeyboardDoubleArrowLeft';
import KeyboardDoubleArrowUpIcon from '@mui/icons-material/KeyboardDoubleArrowUp';
import { addToCart, removeAllFromCart, removeFromCart } from '../../../redux/userSlice';
-import { BasicButton, LightPurpleButton } from '../../../utils/styles';
+
+ ///----> 7th bug<------- /////
+ // FIXED THE IMPORT OF THE BasicButton, LightPurpleButton FROM THE UTILS
+
+import { BasicButton, LightPurpleButton } from '../../../utils/buttonStyles';
+
import { useNavigate } from 'react-router-dom';
-import { updateCustomer } from '../../../redux/userSlice';
+
+
+ ///// ---> FOURTH BUG <----
+ // REPLACE updateCurrentUser with updateCurrentUser in import
+import { updateCurrentUser } from '../../../redux/userSlice';
const Cart = ({ setIsCartOpen }) => {
@@ -31,8 +40,10 @@ const Cart = ({ setIsCartOpen }) => {
const handleRemoveAllFromCart = () => {
dispatch(removeAllFromCart());
};
-
- const totalQuantity = cartDetails.drop((total, item) => total + item.quantity, 0);
+
+ //-------->FIXED THE 48TH BUG ------>
+ // DROP ---->REDUCE
+ const totalQuantity = cartDetails.reduce((total, item) => total + item.quantity, 0);
const totalOGPrice = cartDetails.reduce((total, item) => total + (item.quantity * item.price.mrp), 0);
const totalNewPrice = cartDetails.reduce((total, item) => total + (item.quantity * item.price.cost), 0);
@@ -41,18 +52,26 @@ const Cart = ({ setIsCartOpen }) => {
setIsCartOpen(false)
}
+
+
+ ///// ---> FIFTH BUG <----
+ // REPLACE updateCurrentUser with updateCurrentUser from productBuyingHandler
const productBuyingHandler = (id) => {
console.log(currentUser);
- dispatch(updateCustomer(currentUser, currentUser._id));
+ dispatch(updateCurrentUser(currentUser, currentUser._id));
setIsCartOpen(false)
navigate(`/product/buy/${id}`)
}
+
+ ///// ---> SIXTH BUG <----
+ // REPLACE updateCurrentUser with updateCurrentUser from allProductsBuyingHandler
+
const allProductsBuyingHandler = () => {
console.log(currentUser);
- dispatch(updateCustomer(currentUser, currentUser._id));
+ dispatch(updateCurrentUser(currentUser, currentUser._id));
setIsCartOpen(false)
- navigate("/product/Checkout")
+ navigate("/Checkout")
}
const priceContainerRef = useRef(null);
diff --git a/src/pages/customer/components/OrderSummary.jsx b/src/pages/customer/components/OrderSummary.jsx
index c46975a..28a0a27 100644
--- a/src/pages/customer/components/OrderSummary.jsx
+++ b/src/pages/customer/components/OrderSummary.jsx
@@ -92,8 +92,10 @@ const OrderSummary = ({ handleNext, handleBack }) => {
+ {/* <------23rd bug solved ------> */}
+ {/* replace totalAmount from totalOGPrice */}
- ₹{totalamount - totalNewPrice}
+ ₹{totalOGPrice - totalNewPrice}
diff --git a/src/pages/customer/components/Search.jsx b/src/pages/customer/components/Search.jsx
index bdb80b1..7c61a9c 100644
--- a/src/pages/customer/components/Search.jsx
+++ b/src/pages/customer/components/Search.jsx
@@ -18,7 +18,9 @@ const Search = () => {
const handleSearch = () => {
dispatch(getSearchedProducts("searchProduct", searchTerm));
- if (location.pathname == "/ProductSearch") {
+ //-------->FIXED 42TH BUG <----------//
+
+ if (location.pathname !== "/ProductSearch") {
navigate("/ProductSearch");
}
};
@@ -28,14 +30,23 @@ const Search = () => {
setSearchTerm(etargetvalue)}
+ // fixed 24th bug
+ //replace etargetvalue to e.target.value
+ onChange={(e) => setSearchTerm(e.target.value)}
onKeyDown={(e) => {
- if (ekey !== 'Enter') {
+ // fixed 25th bug
+ //replace eKey to e.Key
+ if (e.key === 'Enter') ///FIXED 43RD BUG
+ {
handleSearch();
}
}}
/>
-
+
+ {/* //---->fixed 44th bug -------> */}
+
+
+
diff --git a/src/pages/customer/pages/CustomerOrders.jsx b/src/pages/customer/pages/CustomerOrders.jsx
index 1e6a81f..9f09367 100644
--- a/src/pages/customer/pages/CustomerOrders.jsx
+++ b/src/pages/customer/pages/CustomerOrders.jsx
@@ -109,9 +109,11 @@ const CustomerOrders = () => {
-
+
- {specificProductData && specificProductData.map((product, index) => (
+ {/* //<------26th bug fixed ----> */}
+
+ {responseSpecificProducts && responseSpecificProducts.map((product, index) => (
diff --git a/src/pages/customer/pages/CustomerSearch.jsx b/src/pages/customer/pages/CustomerSearch.jsx
index 9555be5..7cbccba 100644
--- a/src/pages/customer/pages/CustomerSearch.jsx
+++ b/src/pages/customer/pages/CustomerSearch.jsx
@@ -12,9 +12,9 @@ const CustomerSearch = ({ mode }) => {
const [searchTerm, setSearchTerm] = useState("")
const { filteredProducts } = useSelector(state => state.user);
-
- const handleSearch = () => {
- preventDefault()
+//<-------FIXED 27TH BUG ------->
+ const handleSearch = (e) => {
+ e.preventDefault()
dispatch(getSearchedProducts("searchProduct", searchTerm));
};
diff --git a/src/pages/customer/pages/ViewOrder.jsx b/src/pages/customer/pages/ViewOrder.jsx
index cd03237..6f764a8 100644
--- a/src/pages/customer/pages/ViewOrder.jsx
+++ b/src/pages/customer/pages/ViewOrder.jsx
@@ -153,10 +153,12 @@ const ViewOrder = () => {
- {String(reviewreviewername).charAt(0)}
+ {/* //<---fixed 28th bug ----> */}
+ {/* replace reviewreviewername --->review.reviewer.name */}
+ {String(review.reviewer.name).charAt(0)}
- {reviewreviewername}
+ {review.reviewer.name}
diff --git a/src/pages/seller/components/AccountMenu.jsx b/src/pages/seller/components/AccountMenu.jsx
index d382f97..a2678c7 100644
--- a/src/pages/seller/components/AccountMenu.jsx
+++ b/src/pages/seller/components/AccountMenu.jsx
@@ -5,20 +5,22 @@ import { Link, useNavigate } from 'react-router-dom';
import { useSelector } from 'react-redux';
const AccountMenu = () => {
- const [anchorEl, setAnchorEl] = useEffect(null);
+ const [anchorEl, setAnchorEl] = useState(null); // Bug fix 52: Changed from useEffect to useState
const open = Boolean(anchorEl);
const { currentUser } = useSelector(state => state.user);
- const navigate = useNavigate()
+ const navigate = useNavigate();
const handleClick = (event) => {
setAnchorEl(event.currentTarget);
};
+
const handleClose = () => {
setAnchorEl(null);
};
+
return (
<>
@@ -32,7 +34,7 @@ const AccountMenu = () => {
aria-expanded={open ? 'true' : undefined}
>
- {String(currentUser.name).charAt(0)}
+ {currentUser?.name?.charAt(0)} {/* Bug fix 52: Added optional chaining */}
@@ -52,25 +54,21 @@ const AccountMenu = () => {
>
>
);
}
-export default AccountMenu
+export default AccountMenu;
const styles = {
styledPaper: {
@@ -96,4 +94,4 @@ const styles = {
zIndex: 0,
},
}
-}
\ No newline at end of file
+};
diff --git a/src/pages/seller/components/SalesChart.jsx b/src/pages/seller/components/SalesChart.jsx
index 29f5b2d..2cf59e9 100644
--- a/src/pages/seller/components/SalesChart.jsx
+++ b/src/pages/seller/components/SalesChart.jsx
@@ -15,7 +15,10 @@ import { ChartDatabyYear } from '../../../utils/chartData';
import styled from 'styled-components';
import { useNavigate } from 'react-router-dom';
-const SalesChart = ({ }) => {
+//<-------FIXED THE 30TH BUG --------->
+// TAKING TYPE AS PROP
+
+const SalesChart = ({ type }) => {
const navigate = useNavigate();
diff --git a/src/pages/seller/components/SideBar.jsx b/src/pages/seller/components/SideBar.jsx
index a1b7973..9fd1fa0 100644
--- a/src/pages/seller/components/SideBar.jsx
+++ b/src/pages/seller/components/SideBar.jsx
@@ -12,8 +12,9 @@ import { useSelector } from 'react-redux';
const SideBar = () => {
-
-
+ //<-------fixed 31st bug -------->
+ // using useLocation hook
+ const location = useLocation();
const { currentRole } = useSelector(state => state.user);
return (
diff --git a/src/pages/seller/pages/ShowProducts.jsx b/src/pages/seller/pages/ShowProducts.jsx
index 3103dae..f600fab 100644
--- a/src/pages/seller/pages/ShowProducts.jsx
+++ b/src/pages/seller/pages/ShowProducts.jsx
@@ -9,7 +9,9 @@ import AddCardIcon from '@mui/icons-material/AddCard';
import DeleteIcon from "@mui/icons-material/Delete";
import UploadIcon from '@mui/icons-material/Upload';
import AlertDialogSlide from '../../../components/AlertDialogSlide';
-
+//<-------fixed 32nd bug -------->
+// importing box and grid brom material ui
+import { Box, Grid } from '@mui/material';
const ShowProducts = () => {
const dispatch = useDispatch();
diff --git a/src/pages/seller/pages/ViewProductSeller.jsx b/src/pages/seller/pages/ViewProductSeller.jsx
index 2552a4d..8e7c138 100644
--- a/src/pages/seller/pages/ViewProductSeller.jsx
+++ b/src/pages/seller/pages/ViewProductSeller.jsx
@@ -139,7 +139,7 @@ const ViewProductSeller = () => {
setShowTab(!showTab)}
>
- {showTab ? : }{buttonText}
+ {showTab ? : }Show More
@@ -295,11 +295,13 @@ const ViewProductSeller = () => {
{productDetails.reviews.map((review, index) => (
+ {/* <---fixed 33rd bug -----> */}
+ {/* reviewreviewername ---> 'review.reviewer.name' */}
- {String(reviewreviewername).charAt(0)}
+ {String(review.reviewer.name).charAt(0)}
- {reviewreviewername}
+ {review.reviewer.name}
diff --git a/src/redux/store.js b/src/redux/store.js
index 49d15c7..bc666cf 100644
--- a/src/redux/store.js
+++ b/src/redux/store.js
@@ -2,7 +2,11 @@ import { configureStore } from '@reduxjs/toolkit';
import { userReducer } from './userSlice';
const store = configureStore({
- reducer={
+
+ /// ------> 8TH BUG <-----//
+ // FIX(REPLACE = FROM :)
+
+ reducer :{
user: userReducer,
}
});
diff --git a/src/redux/userHandle.js b/src/redux/userHandle.js
index df46efb..8853480 100644
--- a/src/redux/userHandle.js
+++ b/src/redux/userHandle.js
@@ -49,7 +49,10 @@ export const addStuff = (address, fields) => async (dispatch) => {
try {
const result = await axios.post(`${process.env.REACT_APP_BASE_URL}/${address}`, fields, {
- headers: { 'Content-Type': 'application/json' },---
+
+ // ---> 9th bug fixed <---
+ // REMOVE THE UNWANTED CHARACTERS (---)
+ headers: { 'Content-Type': 'application/json' },
});
if (result.data.message) {
@@ -94,21 +97,19 @@ export const deleteStuff = (id, address) => async (dispatch) => {
dispatch(getError(error));
}
}
+
+ // --------> FIXED 10TH BUG <--------- /////
+ // FIXED THE TRY AND CATCH BLOCK
export const updateCustomer = (fields, id) => async (dispatch) => {
- dispatch(updateCurrentUser(fields));
- await axios.put(`${process.env.REACT_APP_BASE_URL}/CustomerUpdate/${id}`, fields);
-};
-
+ try {
+ dispatch(updateCurrentUser(fields));
+ await axios.put(`${process.env.REACT_APP_BASE_URL}/CustomerUpdate/${id}`, fields);
dispatch(stuffUpdated());
-
- } catch (error) {
-
+ } catch (error) {
dispatch(getError(error));
-
- }
-
}
+};
export const getProductsbySeller = (id) => async (dispatch) => {
dispatch(getRequest());
@@ -158,8 +159,9 @@ export const getProductDetails = (id) => async (dispatch) => {
dispatch(getError(error));
}
}
+// <------fixed 34th bug ----->
-export const getCustomers = (id) => async (dispatch) => {
+export const getCustomers = (address,id) => async (dispatch) => {
dispatch(getRequest());
try {
@@ -201,7 +203,7 @@ export const getSearchedProducts = (address, key) => async (dispatch) => {
dispatch(getSearchFailed(result.data.message));
}
else {
- dispatch(setFilteredProducts(result.files));
+ dispatch(setFilteredProducts(result.data)); //<----FIXED THE 45TH BUG --------->
}
} catch (error) {
diff --git a/src/redux/userSlice.js b/src/redux/userSlice.js
index ec4a697..7508d83 100644
--- a/src/redux/userSlice.js
+++ b/src/redux/userSlice.js
@@ -43,7 +43,7 @@ export const updateShippingDataInLocalStorage = (shippingData) => {
localStorage.setItem('user', JSON.stringify(updatedUser));
};
-const userSlice = createSlice({
+ const userSlice = createSlice({
name: 'user',
initialState,
reducers: {
@@ -170,9 +170,29 @@ const userSlice = createSlice({
},
isTokenValid: (state) => {
- const decodedToken = jwtDecode(state.currentToken);
- if (state.currentToken) { state.isLoggedIn = true;
- } else {
+ //<---fixed the 36th bug ---->
+ // check that token is present before decoding it
+ if (state.currentToken) {
+
+
+ //---->fixed 37th bug------>
+ // added try catch blocks for error handelling
+ try{
+ const decodedToken = jwtDecode(state.currentToken);
+ state.isLoggedIn = true;
+ } catch(error){
+ console.error("Token decoding failed:", error);
+ localStorage.removeItem('user');
+ state.currentUser = null;
+ state.currentRole = null;
+ state.currentToken = null;
+ state.status = 'idle';
+ state.response = null;
+ state.error = null;
+ state.isLoggedIn = false;
+ }
+ }
+ else {
localStorage.removeItem('user');
state.currentUser = null;
state.currentRole = null;
@@ -311,6 +331,14 @@ export const {
removeAllFromCart,
fetchProductDetailsFromCart,
updateCurrentUser,
+
+ // -----> FIXED 11TH BUG <--------//
+ // EXPORTED THE getCustomersListFailed
+ getCustomersListFailed,
+
+ //<------FIXED 12TH BUG ---->
+ // EXPORTING THE setFilteredProducts,
+ setFilteredProducts,
} = userSlice.actions;
diff --git a/src/utils/helperFunctions.js b/src/utils/helperFunctions.js
index 981af27..6983d3a 100644
--- a/src/utils/helperFunctions.js
+++ b/src/utils/helperFunctions.js
@@ -2,6 +2,8 @@ export const timeAgo = (date) => {
const options = { year: 'numeric', month: 'long', day: 'numeric' };
const today = new Date();
+ // <------fixed 35th bug ---->
+ const reviewDate = new Date(date);
const timeDifference = today - reviewDate;
if (timeDifference < 60000) {