From 7121f64c988afd0933e4702b2aa01d6383dac921 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 12:57:31 +0530 Subject: [PATCH 01/46] debugging the function to open and clode the cart --- package-lock.json | 239 ++++++++++++++++++++++++++++++++++++++++++- src/pages/Navbar.jsx | 13 +-- 2 files changed, 243 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3c91622..7074d07 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4192,6 +4192,102 @@ "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==", + "license": "MIT", + "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==", + "license": "MIT", + "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==", + "license": "MIT", + "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==", + "license": "MIT", + "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==", + "license": "MIT", + "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==", + "license": "MIT", + "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==", + "license": "MIT", + "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 +5453,13 @@ "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==", + "license": "MIT", + "peer": true + }, "node_modules/abab": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", @@ -5580,6 +5683,22 @@ "node": ">= 8" } }, + "node_modules/apexcharts": { + "version": "3.51.0", + "resolved": "https://registry.npmjs.org/apexcharts/-/apexcharts-3.51.0.tgz", + "integrity": "sha512-WpCdVdGiJjf9SAyEeg2rl3q5OqCcNqiEmH0+filMraUiH6Vqyn5GFeMMyH0pon44xjNr1G0xzIRERKRmsGEuRA==", + "license": "MIT", + "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 +5713,10 @@ } }, "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==", + "license": "Apache-2.0", "dependencies": { "dequal": "^2.0.3" } @@ -16636,6 +16756,105 @@ "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==", + "license": "MIT", + "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==", + "license": "MIT", + "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==", + "license": "MIT", + "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==", + "license": "MIT", + "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==", + "license": "MIT", + "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==", + "license": "MIT", + "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==", + "license": "MIT", + "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==", + "license": "MIT", + "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 +17330,20 @@ "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==", + "license": "Apache-2.0", + "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/src/pages/Navbar.jsx b/src/pages/Navbar.jsx index e92613c..913ad68 100644 --- a/src/pages/Navbar.jsx +++ b/src/pages/Navbar.jsx @@ -49,13 +49,14 @@ const Navbar = () => { const [isCartOpen, setIsCartOpen] = React.useState(false); - // Cart - const handleOpen Cart = () => { - setIsCartOpen(true); - }; - + const handleOpenCart = () => { - setIsCartOpen(false); + setIsCartOpen(true); + }; + + + const handleCloseCart = () => { + setIsCartOpen(false); }; // Navigation Menu From f59efc3da09b1043389bd5d31fe66d078290d05a Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 13:15:38 +0530 Subject: [PATCH 02/46] debugging react-router in Slide.jsx --- src/pages/Slide.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/Slide.jsx b/src/pages/Slide.jsx index 500ce9e..767d8c4 100644 --- a/src/pages/Slide.jsx +++ b/src/pages/Slide.jsx @@ -1,6 +1,7 @@ import { Divider, Box, Typography, Button, styled, Container } from '@mui/material'; -import { Link, useNavigate } from 'react-router'; +// import { Link, useNavigate } from 'react-router'; +import { Link, useNavigate } from 'react-router-dom'; import Carousel from 'react-multi-carousel'; import "react-multi-carousel/lib/styles.css"; From c4ffce128bce6088ffcf8e2eeb466d2bc33ca524 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 13:30:52 +0530 Subject: [PATCH 03/46] correcting the import statement in Cart.jsx. --- src/pages/customer/components/Cart.jsx | 36 ++++++++++++-------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/pages/customer/components/Cart.jsx b/src/pages/customer/components/Cart.jsx index c086b18..cfa4626 100644 --- a/src/pages/customer/components/Cart.jsx +++ b/src/pages/customer/components/Cart.jsx @@ -5,10 +5,9 @@ import styled from 'styled-components'; 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 { addToCart, removeAllFromCart, removeFromCart, updateCurrentUser } from '../../../redux/userSlice'; // **Correct import statement** import { BasicButton, LightPurpleButton } from '../../../utils/styles'; import { useNavigate } from 'react-router-dom'; -import { updateCustomer } from '../../../redux/userSlice'; const Cart = ({ setIsCartOpen }) => { @@ -32,32 +31,31 @@ const Cart = ({ setIsCartOpen }) => { dispatch(removeAllFromCart()); }; - const totalQuantity = cartDetails.drop((total, item) => total + item.quantity, 0); + const totalQuantity = cartDetails.reduce((total, item) => total + item.quantity, 0); // **Fixed typo: reduce instead of drop** 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); const productViewHandler = (productID) => { - navigate("/product/view/" + productID) - setIsCartOpen(false) - } + navigate("/product/view/" + productID); + setIsCartOpen(false); + }; const productBuyingHandler = (id) => { console.log(currentUser); - dispatch(updateCustomer(currentUser, currentUser._id)); - setIsCartOpen(false) - navigate(`/product/buy/${id}`) - } + dispatch(updateCurrentUser(currentUser, currentUser._id)); // **Updated to use updateCurrentUser** + setIsCartOpen(false); + navigate(`/product/buy/${id}`); + }; const allProductsBuyingHandler = () => { console.log(currentUser); - dispatch(updateCustomer(currentUser, currentUser._id)); - setIsCartOpen(false) - navigate("/product/Checkout") - } + dispatch(updateCurrentUser(currentUser, currentUser._id)); // **Updated to use updateCurrentUser** + setIsCartOpen(false); + navigate("/product/Checkout"); + }; const priceContainerRef = useRef(null); - const handleScrollToBottom = () => { if (priceContainerRef.current) { priceContainerRef.current.scrollIntoView({ behavior: 'smooth' }); @@ -71,15 +69,16 @@ const Cart = ({ setIsCartOpen }) => { firstCartItemRef.current.scrollIntoView({ behavior: 'smooth' }); } }; + return ( { - setIsCartOpen(false) + setIsCartOpen(false); }}> Continue Shopping - {cartDetails.length < 0 || ( + {cartDetails.length > 0 && ( // **Fixed condition to check if cartDetails length is greater than 0** { )} - {cartDetails.length > 0 || ( + {cartDetails.length > 0 && ( // **Fixed condition to check if cartDetails length is greater than 0** )} - ); }; From b9e46e2ffa5b3e5f72dc6f654ad6ed06879f54cc Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 13:35:29 +0530 Subject: [PATCH 04/46] fixing the typo error- reduce instead of drop in Cart.jsx. --- src/pages/customer/components/Cart.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/customer/components/Cart.jsx b/src/pages/customer/components/Cart.jsx index cfa4626..dcad5cc 100644 --- a/src/pages/customer/components/Cart.jsx +++ b/src/pages/customer/components/Cart.jsx @@ -31,7 +31,8 @@ const Cart = ({ setIsCartOpen }) => { dispatch(removeAllFromCart()); }; - const totalQuantity = cartDetails.reduce((total, item) => total + item.quantity, 0); // **Fixed typo: reduce instead of drop** + // **Fixed typo: reduce instead of drop** + 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); From 442a2e9878ce4cb1943394c18f3c7180e7569228 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 13:37:07 +0530 Subject: [PATCH 05/46] Updated to use updateCurrentUser --- src/pages/customer/components/Cart.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/customer/components/Cart.jsx b/src/pages/customer/components/Cart.jsx index dcad5cc..e7cbb50 100644 --- a/src/pages/customer/components/Cart.jsx +++ b/src/pages/customer/components/Cart.jsx @@ -43,7 +43,8 @@ const Cart = ({ setIsCartOpen }) => { const productBuyingHandler = (id) => { console.log(currentUser); - dispatch(updateCurrentUser(currentUser, currentUser._id)); // **Updated to use updateCurrentUser** + // **Updated to use updateCurrentUser** + dispatch(updateCurrentUser(currentUser, currentUser._id)); setIsCartOpen(false); navigate(`/product/buy/${id}`); }; From 7f5572f0c68a87342343bf148790a8aaa6936dd2 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 13:47:18 +0530 Subject: [PATCH 06/46] DefiningLightPurpleButton locally --- src/pages/customer/components/Cart.jsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/pages/customer/components/Cart.jsx b/src/pages/customer/components/Cart.jsx index e7cbb50..90f12a2 100644 --- a/src/pages/customer/components/Cart.jsx +++ b/src/pages/customer/components/Cart.jsx @@ -9,6 +9,17 @@ import { addToCart, removeAllFromCart, removeFromCart, updateCurrentUser } from import { BasicButton, LightPurpleButton } from '../../../utils/styles'; import { useNavigate } from 'react-router-dom'; +// **Define LightPurpleButton locally** +const LightPurpleButton = styled(Button)` + background-color: #D1C4E9; + color: #512DA8; + &:hover { + background-color: #B39DDB; + } +`; + + + const Cart = ({ setIsCartOpen }) => { const dispatch = useDispatch(); From 7c1df52dbe4a8492249200e56cd16e37051a0fb3 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 13:52:02 +0530 Subject: [PATCH 07/46] eliminating the double defination of LightPurpleButton in Cart.jsx --- src/pages/customer/components/Cart.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/customer/components/Cart.jsx b/src/pages/customer/components/Cart.jsx index 90f12a2..cc792ae 100644 --- a/src/pages/customer/components/Cart.jsx +++ b/src/pages/customer/components/Cart.jsx @@ -6,7 +6,7 @@ import emptyCart from "../../../assets/cartimg.png" import KeyboardDoubleArrowLeftIcon from '@mui/icons-material/KeyboardDoubleArrowLeft'; import KeyboardDoubleArrowUpIcon from '@mui/icons-material/KeyboardDoubleArrowUp'; import { addToCart, removeAllFromCart, removeFromCart, updateCurrentUser } from '../../../redux/userSlice'; // **Correct import statement** -import { BasicButton, LightPurpleButton } from '../../../utils/styles'; +import { BasicButton } from '../../../utils/styles'; import { useNavigate } from 'react-router-dom'; // **Define LightPurpleButton locally** From 2a12970e2f0c78d580854aa2b1fcafcbdb99a8b2 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 14:10:43 +0530 Subject: [PATCH 08/46] Import Button from @mui/material in styles.js file --- src/utils/styles.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/styles.js b/src/utils/styles.js index 6def259..0aaa5ec 100644 --- a/src/utils/styles.js +++ b/src/utils/styles.js @@ -5,6 +5,7 @@ import { tableCellClasses, Drawer as MuiDrawer, AppBar as MuiAppBar, + Button // **Import Button from @mui/material** } from "@mui/material"; import { Link } from "react-scroll"; From 5a285e8e9f68486c3b6d5ad14e55a00299a6a148 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 14:12:40 +0530 Subject: [PATCH 09/46] Defining and exporting BasicButton in styles.js file --- src/utils/styles.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/utils/styles.js b/src/utils/styles.js index 0aaa5ec..4b6a25a 100644 --- a/src/utils/styles.js +++ b/src/utils/styles.js @@ -77,4 +77,13 @@ export const Drawer = styled(MuiDrawer, { shouldForwardProp: (prop) => prop !== export const NavLogo = styled(Link)` display: flex; +`; + + // **Define and export BasicButton** +export const BasicButton = styled(Button)` +background-color: #8E24AA; +color: white; +&:hover { + background-color: #7B1FA2; +} `; \ No newline at end of file From 54e1a1e9431f7495d0201dfb9ed4068e8459633d Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 14:13:53 +0530 Subject: [PATCH 10/46] Defining and exporting LightPurpleButton --- src/utils/styles.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/utils/styles.js b/src/utils/styles.js index 4b6a25a..bb77ff0 100644 --- a/src/utils/styles.js +++ b/src/utils/styles.js @@ -86,4 +86,13 @@ color: white; &:hover { background-color: #7B1FA2; } +`; + +// **Define and export LightPurpleButton** +export const LightPurpleButton = styled(Button)` + background-color: #D1C4E9; + color: #512DA8; + &:hover { + background-color: #B39DDB; + } `; \ No newline at end of file From 14f450cffe7cfc6f77533575e043aa40f54ed407 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 14:18:24 +0530 Subject: [PATCH 11/46] removing the locally defined LightPurpleButton in Cart.jsx file --- src/pages/customer/components/Cart.jsx | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/pages/customer/components/Cart.jsx b/src/pages/customer/components/Cart.jsx index cc792ae..16d642e 100644 --- a/src/pages/customer/components/Cart.jsx +++ b/src/pages/customer/components/Cart.jsx @@ -6,18 +6,9 @@ import emptyCart from "../../../assets/cartimg.png" import KeyboardDoubleArrowLeftIcon from '@mui/icons-material/KeyboardDoubleArrowLeft'; import KeyboardDoubleArrowUpIcon from '@mui/icons-material/KeyboardDoubleArrowUp'; import { addToCart, removeAllFromCart, removeFromCart, updateCurrentUser } from '../../../redux/userSlice'; // **Correct import statement** -import { BasicButton } from '../../../utils/styles'; +import { BasicButton, LightPurpleButton } from '../../../utils/styles'; import { useNavigate } from 'react-router-dom'; -// **Define LightPurpleButton locally** -const LightPurpleButton = styled(Button)` - background-color: #D1C4E9; - color: #512DA8; - &:hover { - background-color: #B39DDB; - } -`; - const Cart = ({ setIsCartOpen }) => { From abc9ea6196b86cb9820a87028e0c8b934d2f1c82 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 14:27:43 +0530 Subject: [PATCH 12/46] replacing "=" with "=" for "reducer" in store.js file --- src/redux/store.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/redux/store.js b/src/redux/store.js index 49d15c7..ba62e75 100644 --- a/src/redux/store.js +++ b/src/redux/store.js @@ -2,7 +2,8 @@ import { configureStore } from '@reduxjs/toolkit'; import { userReducer } from './userSlice'; const store = configureStore({ - reducer={ + // : is used instead "=" + reducer:{ user: userReducer, } }); From 5af6a14428017810b63c91a1f0053b352bdd387d Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 14:40:46 +0530 Subject: [PATCH 13/46] defining the missinig try block in userHandle.js fille --- src/redux/userHandle.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/redux/userHandle.js b/src/redux/userHandle.js index df46efb..1aaf37d 100644 --- a/src/redux/userHandle.js +++ b/src/redux/userHandle.js @@ -49,7 +49,7 @@ 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' },--- + headers: { 'Content-Type': 'application/json' }, }); if (result.data.message) { @@ -82,7 +82,7 @@ export const updateStuff = (fields, id, address) => async (dispatch) => { export const deleteStuff = (id, address) => async (dispatch) => { dispatch(getRequest()); - +// ** defining the missing try block here** try { const result = await axios.delete(`${process.env.REACT_APP_BASE_URL}/${address}/${id}`); if (result.data.message) { @@ -97,18 +97,21 @@ export const deleteStuff = (id, address) => async (dispatch) => { export const updateCustomer = (fields, id) => async (dispatch) => { dispatch(updateCurrentUser(fields)); - await axios.put(`${process.env.REACT_APP_BASE_URL}/CustomerUpdate/${id}`, fields); -}; - + try{ + const result=await axios.put(`${process.env.REACT_APP_BASE_URL}/CustomerUpdate/${id}`, fields); + if (result.data.message) { + dispatch(getFailed(result.data.message)); + } else { + dispatch(stuffUpdated()); - + } } catch (error) { dispatch(getError(error)); - } + }} - } + export const getProductsbySeller = (id) => async (dispatch) => { dispatch(getRequest()); From 627a678a0c1e6f39081a033e0f73e2967fb6c683 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 14:52:20 +0530 Subject: [PATCH 14/46] exportnig the getCustomersListFailed from the userSlice.js file --- src/redux/userSlice.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/redux/userSlice.js b/src/redux/userSlice.js index ec4a697..5636885 100644 --- a/src/redux/userSlice.js +++ b/src/redux/userSlice.js @@ -299,6 +299,7 @@ export const { getProductsFailed, getSellerProductsFailed, getProductDetailsFailed, + getCustomersListFailed, getFailed, getError, getSearchFailed, From 8e2c16d81584a60ac058c60d023ca5addbad9ff9 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 14:54:28 +0530 Subject: [PATCH 15/46] exporting the setFilteredProducts from the userSlice.js file --- src/redux/userSlice.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/redux/userSlice.js b/src/redux/userSlice.js index 5636885..ae482cd 100644 --- a/src/redux/userSlice.js +++ b/src/redux/userSlice.js @@ -312,6 +312,7 @@ export const { removeAllFromCart, fetchProductDetailsFromCart, updateCurrentUser, + setFilteredProducts, } = userSlice.actions; From 6e43473bd671da78bb78fa7d5c6e455df565a969 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 15:06:20 +0530 Subject: [PATCH 16/46] recorrecting the import file path as userSlice instead usedHandle in popup.jsx file --- src/components/Popup.jsx | 2 +- src/redux/userHandle.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Popup.jsx b/src/components/Popup.jsx index 8665751..d80c610 100644 --- a/src/components/Popup.jsx +++ b/src/components/Popup.jsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { useDispatch } from 'react-redux'; -import { underControl } from '../redux/userHandle'; +import { underControl } from '../redux/userSlice'; // recorrecting the file path as userSlice instead userHandle import MuiAlert from '@mui/material/Alert'; import { Snackbar } from '@mui/material'; diff --git a/src/redux/userHandle.js b/src/redux/userHandle.js index 1aaf37d..d77179c 100644 --- a/src/redux/userHandle.js +++ b/src/redux/userHandle.js @@ -24,6 +24,7 @@ import { getSpecificProductsFailed, specificProductSuccess, updateCurrentUser, + } from './userSlice'; export const authUser = (fields, role, mode) => async (dispatch) => { From dbcfd601202c997f57d578a67273ecb8c3133635 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 15:34:07 +0530 Subject: [PATCH 17/46] defining the taskHandler() function into the AlertDialogSlide.jsx file --- src/components/AlertDialogSlide.jsx | 3 +++ src/redux/userSlice.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/AlertDialogSlide.jsx b/src/components/AlertDialogSlide.jsx index 8a12e5b..0a1f931 100644 --- a/src/components/AlertDialogSlide.jsx +++ b/src/components/AlertDialogSlide.jsx @@ -6,6 +6,9 @@ const AlertDialogSlide = ({ dialog, showDialog, setShowDialog }) => { const handleClose = () => { setShowDialog(false); }; + const taskHandler = () => { // defining the taskHandler function; + setShowDialog(false); + }; return ( Date: Sat, 3 Aug 2024 15:46:12 +0530 Subject: [PATCH 18/46] Adding the useNevigate hook to define 'nevigate' into the Products.jsx file --- src/components/Products.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Products.jsx b/src/components/Products.jsx index dba78bc..d719f11 100644 --- a/src/components/Products.jsx +++ b/src/components/Products.jsx @@ -10,6 +10,7 @@ import { addStuff } from '../redux/userHandle'; const Products = ({}) => { const dispatch = useDispatch(); + const navigate = useNavigate(); // **Added the useNavigate hook to define `navigate`** const itemsPerPage = 9; From 08597861269ed11769d3243174c7cde159fd2739 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 15:53:49 +0530 Subject: [PATCH 19/46] Corrected useSelector to select from the state --- src/components/Products.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Products.jsx b/src/components/Products.jsx index d719f11..069eb26 100644 --- a/src/components/Products.jsx +++ b/src/components/Products.jsx @@ -14,7 +14,7 @@ const Products = ({}) => { const itemsPerPage = 9; - const { currentRole, responseSearch } = useSelector(); + const { currentRole, responseSearch } = useSelector((state) => state.user); // **Corrected useSelector to select from the state** const [currentPage, setCurrentPage] = useState(1); const [showPopup, setShowPopup] = useState(false); const [message, setMessage] = useState(""); From 1eec052a39a6c141576223f641bc4e3faa3581f3 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 15:54:56 +0530 Subject: [PATCH 20/46] Fixed the calculation for indexOfFirstItem --- src/components/Products.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Products.jsx b/src/components/Products.jsx index 069eb26..4e63e35 100644 --- a/src/components/Products.jsx +++ b/src/components/Products.jsx @@ -20,7 +20,7 @@ const Products = ({}) => { const [message, setMessage] = useState(""); const indexOfLastItem = currentPage * itemsPerPage; - const indexOfFirstItem = indexOfLastItem + itemsPerPage; + const indexOfFirstItem = indexOfLastItem - itemsPerPage; // **Fixed the calculation for indexOfFirstItem** const currentItems = (indexOfFirstItem, indexOfLastItem); const handleAddToCart = (event, product) => { From ddc047b88a391a08c7608a4766136a30d19ee42d Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 15:57:23 +0530 Subject: [PATCH 21/46] Updated to use productData for currentItems --- src/components/Products.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Products.jsx b/src/components/Products.jsx index 4e63e35..922dc36 100644 --- a/src/components/Products.jsx +++ b/src/components/Products.jsx @@ -21,7 +21,7 @@ const Products = ({}) => { const indexOfLastItem = currentPage * itemsPerPage; const indexOfFirstItem = indexOfLastItem - itemsPerPage; // **Fixed the calculation for indexOfFirstItem** - const currentItems = (indexOfFirstItem, indexOfLastItem); + const currentItems = productData.slice(indexOfFirstItem, indexOfLastItem); // **Updated to use productData for currentItems** const handleAddToCart = (event, product) => { event.stopPropagation(); From 22ea97de96982791152f4e997dad359e086307d0 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 15:59:32 +0530 Subject: [PATCH 22/46] Added check for empty productData --- src/components/Products.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Products.jsx b/src/components/Products.jsx index 922dc36..fea51de 100644 --- a/src/components/Products.jsx +++ b/src/components/Products.jsx @@ -40,7 +40,7 @@ const Products = ({}) => { setShowPopup(true) }; - if (!responseSearch) { + if (!productData || productData.length === 0) { // **Added check for empty productData** return
Product not found
; } From fe20d549b2c39a73296dcf1913521b8c3216a3eb Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 16:03:12 +0530 Subject: [PATCH 23/46] updating the text error to productData --- src/components/Products.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Products.jsx b/src/components/Products.jsx index fea51de..59ded1c 100644 --- a/src/components/Products.jsx +++ b/src/components/Products.jsx @@ -14,7 +14,7 @@ const Products = ({}) => { const itemsPerPage = 9; - const { currentRole, responseSearch } = useSelector((state) => state.user); // **Corrected useSelector to select from the state** + const { currentRole, productData } = useSelector((state) => state.user); // **Corrected useSelector to select from the state** const [currentPage, setCurrentPage] = useState(1); const [showPopup, setShowPopup] = useState(false); const [message, setMessage] = useState(""); From 025eab7744e253e44cdf0c3e41a63b7af0b7486f Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 16:10:16 +0530 Subject: [PATCH 24/46] Added SpeedDialAction import into the SpeedDIalTempalate file. --- src/components/SpeedDialTemplate.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SpeedDialTemplate.jsx b/src/components/SpeedDialTemplate.jsx index fb93bad..dc9e557 100644 --- a/src/components/SpeedDialTemplate.jsx +++ b/src/components/SpeedDialTemplate.jsx @@ -1,5 +1,5 @@ import React from 'react' -import { SpeedDial, styled } from '@mui/material'; +import { SpeedDial, SpeedDialAction, styled } from '@mui/material'; // **Added SpeedDialAction import** import TuneIcon from '@mui/icons-material/Tune'; const SpeedDialTemplate = ({ actions }) => { From 275f1109b928041e3b8975e9b9d29dab535ac7ca Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 16:16:57 +0530 Subject: [PATCH 25/46] Added tableCellClasses import into the table template file. --- src/components/TableTemplate.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/TableTemplate.jsx b/src/components/TableTemplate.jsx index bf8ff1e..a15d19f 100644 --- a/src/components/TableTemplate.jsx +++ b/src/components/TableTemplate.jsx @@ -1,5 +1,6 @@ import React, {useState} from 'react' -import {Table, TableBody, TableCell, TableContainer, TableRow, styled} from '@mui/material'; +import { Table, TableBody, TableCell, TableContainer, TableRow, styled, tableCellClasses } from '@mui/material'; // **Added tableCellClasses import** + const TableTemplate = ({columns, rows}) => { const [page, setPage] = useState(0); From f349bd068a4ed5e2f761f31d0297a3dfc24fc99b Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 16:23:56 +0530 Subject: [PATCH 26/46] Fixed slicing logic --- src/components/TableTemplate.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TableTemplate.jsx b/src/components/TableTemplate.jsx index a15d19f..062cbe7 100644 --- a/src/components/TableTemplate.jsx +++ b/src/components/TableTemplate.jsx @@ -24,7 +24,7 @@ const TableTemplate = ({columns, rows}) => { {rows - .slice(page * rowsPerPage, page == rowsPerPage + rowsPerPage) + .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) // **Fixed slicing logic** .map((row) => { return ( From 512c71548b33c71483779d805638bdfe78dcbc2f Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 16:27:00 +0530 Subject: [PATCH 27/46] Fixed tabIndex value --- src/components/TableTemplate.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TableTemplate.jsx b/src/components/TableTemplate.jsx index 062cbe7..26c6e53 100644 --- a/src/components/TableTemplate.jsx +++ b/src/components/TableTemplate.jsx @@ -27,7 +27,7 @@ const TableTemplate = ({columns, rows}) => { .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) // **Fixed slicing logic** .map((row) => { return ( - + {/* Fixed tabIndex value */} {columns.map((column) => { const value = row[column.id]; return ( From a13761bf873a70e495e3ab3ba2b9cb7cf0ff5319 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 16:27:51 +0530 Subject: [PATCH 28/46] Fixed key and column.id --- src/components/TableTemplate.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TableTemplate.jsx b/src/components/TableTemplate.jsx index 26c6e53..2ce3252 100644 --- a/src/components/TableTemplate.jsx +++ b/src/components/TableTemplate.jsx @@ -31,7 +31,7 @@ const TableTemplate = ({columns, rows}) => { {columns.map((column) => { const value = row[column.id]; return ( - + {/* Fixed key and column.id */} { column.format && typeof value === 'number' ? column.format(id) From 40f93a056548fbbbe84d241c229c9e70eb86129c Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 16:28:51 +0530 Subject: [PATCH 29/46] Fixed format function call --- src/components/TableTemplate.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TableTemplate.jsx b/src/components/TableTemplate.jsx index 2ce3252..d1e7f11 100644 --- a/src/components/TableTemplate.jsx +++ b/src/components/TableTemplate.jsx @@ -34,7 +34,7 @@ const TableTemplate = ({columns, rows}) => { {/* Fixed key and column.id */} { column.format && typeof value === 'number' - ? column.format(id) + ? column.format(value) // **Fixed format function call** : value } From 777fecb1231edb8d34127ae34d7e230048214362 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 16:48:30 +0530 Subject: [PATCH 30/46] corrected typo error as anchor instead ancor --- src/pages/Navbar.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Navbar.jsx b/src/pages/Navbar.jsx index 913ad68..4c27117 100644 --- a/src/pages/Navbar.jsx +++ b/src/pages/Navbar.jsx @@ -38,7 +38,7 @@ const Navbar = () => { console.log(currentUser); dispatch(updateCustomer(currentUser, currentUser._id)); } - }, [currentRole, currentUser, dispatch, ancorElNav]) + }, [currentRole, currentUser, dispatch, anchorElNav]) // corrected typo error as anchor instead ancor const [anchorElNav, setAnchorElNav] = React.useState(null); const [anchorElUser, setAnchorElUser] = React.useState(null); From b241d90a7971caee58fa4c0a5b9c624652e89953 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 16:55:45 +0530 Subject: [PATCH 31/46] recorrected totalprice as totalOGPrice --- src/pages/customer/components/OrderSummary.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/customer/components/OrderSummary.jsx b/src/pages/customer/components/OrderSummary.jsx index c46975a..fa3cbc3 100644 --- a/src/pages/customer/components/OrderSummary.jsx +++ b/src/pages/customer/components/OrderSummary.jsx @@ -93,7 +93,8 @@ const OrderSummary = ({ handleNext, handleBack }) => { - ₹{totalamount - totalNewPrice} + {/* //recorrected totalprice as totalOGPrice; */} + ₹{totalOGPrice - totalNewPrice} From c3657f1039a82ab77e7520b8c0e10830328f24ea Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 17:00:08 +0530 Subject: [PATCH 32/46] Fixed typo missing point separator --- src/pages/customer/components/Search.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/customer/components/Search.jsx b/src/pages/customer/components/Search.jsx index bdb80b1..bc2898f 100644 --- a/src/pages/customer/components/Search.jsx +++ b/src/pages/customer/components/Search.jsx @@ -28,9 +28,9 @@ const Search = () => { setSearchTerm(etargetvalue)} + onChange={(e) => setSearchTerm(e.target.value)} {/* Fixed typo here */} onKeyDown={(e) => { - if (ekey !== 'Enter') { + if (e.key !== 'Enter') { {/* Fixed typo here */} handleSearch(); } }} From 534a6005f06d10ce8fa4c35932f0914acffeceb7 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 17:11:20 +0530 Subject: [PATCH 33/46] debuggnig to Check if responseSpecificProducts is empty and handle rendering accordingly --- src/pages/customer/components/Search.jsx | 3 +- src/pages/customer/pages/CustomerOrders.jsx | 31 +++++++++------------ 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/pages/customer/components/Search.jsx b/src/pages/customer/components/Search.jsx index bc2898f..a07c960 100644 --- a/src/pages/customer/components/Search.jsx +++ b/src/pages/customer/components/Search.jsx @@ -28,7 +28,8 @@ const Search = () => { setSearchTerm(e.target.value)} {/* Fixed typo here */} + + onChange={(e) => setSearchTerm(e.target.value)} onKeyDown={(e) => { if (e.key !== 'Enter') { {/* Fixed typo here */} handleSearch(); diff --git a/src/pages/customer/pages/CustomerOrders.jsx b/src/pages/customer/pages/CustomerOrders.jsx index 1e6a81f..e3cdb36 100644 --- a/src/pages/customer/pages/CustomerOrders.jsx +++ b/src/pages/customer/pages/CustomerOrders.jsx @@ -14,9 +14,7 @@ import { useDispatch, useSelector } from 'react-redux'; import { getSpecificProducts } from '../../../redux/userHandle'; const CustomerOrders = () => { - - const dispatch = useDispatch() - + const dispatch = useDispatch(); const { currentUser, loading, responseSpecificProducts } = useSelector(state => state.user); useEffect(() => { @@ -46,17 +44,14 @@ const CustomerOrders = () => { return ( <> - {loading ? -

- Loading... -

- : + {loading ? ( +

Loading...

+ ) : ( <> - {responseSpecificProducts ? -

- No Orders Till Now -

- : + {/* Debugging: Check if responseSpecificProducts is empty and handle rendering accordingly */} + {responseSpecificProducts && responseSpecificProducts.length === 0 ? ( +

No Orders Till Now

+ ) : ( My Orders @@ -111,19 +106,19 @@ const CustomerOrders = () => { - {specificProductData && specificProductData.map((product, index) => ( + {/* Debugging: Use responseSpecificProducts instead of specificProductData */} + {responseSpecificProducts && responseSpecificProducts.map((product, index) => ( ))} - - } + )} - } + )} ); } -export default CustomerOrders \ No newline at end of file +export default CustomerOrders; From e2bbc9ca7d1c14cafa77475478f5757cff9689dd Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 17:14:30 +0530 Subject: [PATCH 34/46] Styled component SearchContainer as a form element --- src/pages/customer/pages/CustomerSearch.jsx | 65 +++++++++------------ 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/src/pages/customer/pages/CustomerSearch.jsx b/src/pages/customer/pages/CustomerSearch.jsx index 9555be5..bb5a305 100644 --- a/src/pages/customer/pages/CustomerSearch.jsx +++ b/src/pages/customer/pages/CustomerSearch.jsx @@ -6,56 +6,49 @@ import { useDispatch, useSelector } from 'react-redux'; import { getSearchedProducts } from '../../../redux/userHandle'; const CustomerSearch = ({ mode }) => { - const dispatch = useDispatch(); - - const [searchTerm, setSearchTerm] = useState("") + const [searchTerm, setSearchTerm] = useState(""); const { filteredProducts } = useSelector(state => state.user); - const handleSearch = () => { - preventDefault() + // Debugging: Updated handleSearch to use event parameter and call preventDefault + const handleSearch = (event) => { + event.preventDefault(); // Prevent the default form submission behavior dispatch(getSearchedProducts("searchProduct", searchTerm)); }; return (
- { - mode === "Mobile" ? - - <> - - setSearchTerm(e.target.value)} - /> - - { - searchTerm && - } - - : - <> - { - filteredProducts && - } - - } - + {mode === "Mobile" ? ( + <> + + setSearchTerm(e.target.value)} + /> + + {searchTerm && } + + ) : ( + <> + {filteredProducts && } + + )}
); }; +// Styled component SearchContainer as a form element const SearchContainer = styled('form')({ display: 'flex', justifyContent: 'center', From 606f6ca763b26099fe0f20eac3b85976259f4e83 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 17:16:07 +0530 Subject: [PATCH 35/46] Updated handleSearch to use event parameter and call preventDefault --- src/pages/customer/pages/CustomerSearch.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/customer/pages/CustomerSearch.jsx b/src/pages/customer/pages/CustomerSearch.jsx index bb5a305..ba16db8 100644 --- a/src/pages/customer/pages/CustomerSearch.jsx +++ b/src/pages/customer/pages/CustomerSearch.jsx @@ -11,7 +11,7 @@ const CustomerSearch = ({ mode }) => { const { filteredProducts } = useSelector(state => state.user); - // Debugging: Updated handleSearch to use event parameter and call preventDefault + // Updated handleSearch to use event parameter and call preventDefault const handleSearch = (event) => { event.preventDefault(); // Prevent the default form submission behavior From 3d227af0c24a463e63d76f101c32250211a9a83b Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 17:24:21 +0530 Subject: [PATCH 36/46] recorrecting the typo error as review.reviewer.name --- src/pages/customer/pages/ViewOrder.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/customer/pages/ViewOrder.jsx b/src/pages/customer/pages/ViewOrder.jsx index cd03237..da1de4c 100644 --- a/src/pages/customer/pages/ViewOrder.jsx +++ b/src/pages/customer/pages/ViewOrder.jsx @@ -153,10 +153,10 @@ const ViewOrder = () => { - {String(reviewreviewername).charAt(0)} + {String(review.reviewer.name).charAt(0)} - {reviewreviewername} + {review.reviewer.name} {/* recorrecting the typo error as review.reviewer.name */}
From 2a001a68bfd729bd28db5b265eb9376e089b3608 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 17:36:14 +0530 Subject: [PATCH 37/46] Changed useEffect to useState --- src/pages/seller/components/AccountMenu.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/seller/components/AccountMenu.jsx b/src/pages/seller/components/AccountMenu.jsx index d382f97..ee65dff 100644 --- a/src/pages/seller/components/AccountMenu.jsx +++ b/src/pages/seller/components/AccountMenu.jsx @@ -5,7 +5,7 @@ import { Link, useNavigate } from 'react-router-dom'; import { useSelector } from 'react-redux'; const AccountMenu = () => { - const [anchorEl, setAnchorEl] = useEffect(null); + const [anchorEl, setAnchorEl] = useState(null); // Changed useEffect to useState const open = Boolean(anchorEl); From 07112043f049586b1c85dc17d3f486178f70bff1 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 17:39:07 +0530 Subject: [PATCH 38/46] Added default value for type prop --- src/pages/seller/components/SalesChart.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/seller/components/SalesChart.jsx b/src/pages/seller/components/SalesChart.jsx index 29f5b2d..8983a8b 100644 --- a/src/pages/seller/components/SalesChart.jsx +++ b/src/pages/seller/components/SalesChart.jsx @@ -15,7 +15,7 @@ import { ChartDatabyYear } from '../../../utils/chartData'; import styled from 'styled-components'; import { useNavigate } from 'react-router-dom'; -const SalesChart = ({ }) => { +const SalesChart = ({ type = 'line' }) => { // Added default value for type prop const navigate = useNavigate(); From b056bd26ed4cf2538aa50fa2630b7c8c85322d38 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 17:42:26 +0530 Subject: [PATCH 39/46] Used the useLocation hook to get the current path --- src/pages/seller/components/SideBar.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/seller/components/SideBar.jsx b/src/pages/seller/components/SideBar.jsx index a1b7973..89c5a64 100644 --- a/src/pages/seller/components/SideBar.jsx +++ b/src/pages/seller/components/SideBar.jsx @@ -12,7 +12,7 @@ import { useSelector } from 'react-redux'; const SideBar = () => { - + const location = useLocation(); //Use the useLocation hook to get the current path const { currentRole } = useSelector(state => state.user); From 0b33bc6d16973fc025a23ae335599da9a9b05fad Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 17:45:32 +0530 Subject: [PATCH 40/46] Import Box and Grid from MUI --- src/pages/seller/pages/ShowProducts.jsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pages/seller/pages/ShowProducts.jsx b/src/pages/seller/pages/ShowProducts.jsx index 3103dae..fc6d043 100644 --- a/src/pages/seller/pages/ShowProducts.jsx +++ b/src/pages/seller/pages/ShowProducts.jsx @@ -10,6 +10,9 @@ import DeleteIcon from "@mui/icons-material/Delete"; import UploadIcon from '@mui/icons-material/Upload'; import AlertDialogSlide from '../../../components/AlertDialogSlide'; +// Import Box and Grid from MUI +import { Box, Grid } from '@mui/material'; + const ShowProducts = () => { const dispatch = useDispatch(); From a0c89459a80d4e42b84d7c4de6288c9a44e966d3 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 17:53:20 +0530 Subject: [PATCH 41/46] Fixed button text --- src/pages/seller/pages/ViewProductSeller.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/seller/pages/ViewProductSeller.jsx b/src/pages/seller/pages/ViewProductSeller.jsx index 2552a4d..a34e203 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 ? : } {/* Fixed button text */} From a2be7e551d918e546c465d8d848897220c63a3ee Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 17:55:07 +0530 Subject: [PATCH 42/46] Fixed dialog message --- src/pages/seller/pages/ViewProductSeller.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/seller/pages/ViewProductSeller.jsx b/src/pages/seller/pages/ViewProductSeller.jsx index a34e203..3011486 100644 --- a/src/pages/seller/pages/ViewProductSeller.jsx +++ b/src/pages/seller/pages/ViewProductSeller.jsx @@ -283,8 +283,8 @@ const ViewProductSeller = () => { {productDetails.reviews && productDetails.reviews.length > 0 && { - setDialog("Do you want to delete all notices ?") - setShowDialog(true) + setDialog("Do you want to delete all reviews?"); {/* Fixed dialog message */} + setShowDialog(true); }}> Remove All Reviews } From 5031d5cd1570fcb1413270f0f1c3e65a26921a47 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 17:57:16 +0530 Subject: [PATCH 43/46] fixed typo as review.reviewerName --- src/pages/seller/pages/ViewProductSeller.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/seller/pages/ViewProductSeller.jsx b/src/pages/seller/pages/ViewProductSeller.jsx index 3011486..cbf7186 100644 --- a/src/pages/seller/pages/ViewProductSeller.jsx +++ b/src/pages/seller/pages/ViewProductSeller.jsx @@ -296,10 +296,10 @@ const ViewProductSeller = () => { - {String(reviewreviewername).charAt(0)} + {String(review.reviewerName).charAt(0)} {/* Fixed typo */} - {reviewreviewername} + {review.reviewername} {/* Fixed typo */}
From 7806fc1378f3570b25bdd4f9f9848edd7250dd53 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 18:01:47 +0530 Subject: [PATCH 44/46] Fixed the undefined 'reviewDate' issue --- src/utils/helperFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/helperFunctions.js b/src/utils/helperFunctions.js index 981af27..6f1edf9 100644 --- a/src/utils/helperFunctions.js +++ b/src/utils/helperFunctions.js @@ -2,7 +2,7 @@ export const timeAgo = (date) => { const options = { year: 'numeric', month: 'long', day: 'numeric' }; const today = new Date(); - const timeDifference = today - reviewDate; + const timeDifference = today - new Date(date); // Fixed the undefined 'reviewDate' issue if (timeDifference < 60000) { return 'just now'; From 18e1463554b724aae6b49e636a4415d48c7fccf4 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 18:20:27 +0530 Subject: [PATCH 45/46] adding address parameter to getCustomers function --- src/redux/userHandle.js | 4 ++-- src/utils/helperFunctions.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/redux/userHandle.js b/src/redux/userHandle.js index d77179c..3b99266 100644 --- a/src/redux/userHandle.js +++ b/src/redux/userHandle.js @@ -162,8 +162,8 @@ export const getProductDetails = (id) => async (dispatch) => { dispatch(getError(error)); } } - -export const getCustomers = (id) => async (dispatch) => { +// The 'address' parameter is now added to this function +export const getCustomers = (id, address) => async (dispatch) => { dispatch(getRequest()); try { diff --git a/src/utils/helperFunctions.js b/src/utils/helperFunctions.js index 6f1edf9..ce1ba0a 100644 --- a/src/utils/helperFunctions.js +++ b/src/utils/helperFunctions.js @@ -13,7 +13,7 @@ export const timeAgo = (date) => { const hours = Math.floor(timeDifference / 3600000); return `${hours} hour${hours !== 1 ? 's' : ''} ago`; } else { - return `on ${reviewDate.toLocaleDateString(undefined, options)}`; + return `on ${new Date(date).toLocaleDateString(undefined, options)}`; } }; From 241d2a75a99b9800a804387f647af5e5fa5cad53 Mon Sep 17 00:00:00 2001 From: Nauser Date: Sat, 3 Aug 2024 18:33:52 +0530 Subject: [PATCH 46/46] Use MUI Button as a placeholder --- src/components/TableTemplate.jsx | 82 ++++++++++++++++---------------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/src/components/TableTemplate.jsx b/src/components/TableTemplate.jsx index d1e7f11..0474877 100644 --- a/src/components/TableTemplate.jsx +++ b/src/components/TableTemplate.jsx @@ -1,10 +1,11 @@ -import React, {useState} from 'react' -import { Table, TableBody, TableCell, TableContainer, TableRow, styled, tableCellClasses } from '@mui/material'; // **Added tableCellClasses import** +import React, { useState } from 'react'; +import { Table, TableBody, TableCell, TableContainer, TableRow, TablePagination, styled, tableCellClasses } from '@mui/material'; +import Button from '@mui/material/Button'; // Use MUI Button as a placeholder - -const TableTemplate = ({columns, rows}) => { +const TableTemplate = ({ columns, rows }) => { const [page, setPage] = useState(0); const [rowsPerPage, setRowsPerPage] = useState(5); + return ( <> @@ -14,8 +15,9 @@ const TableTemplate = ({columns, rows}) => { + {column.label} {/* Add column header content */} ))} @@ -24,48 +26,44 @@ const TableTemplate = ({columns, rows}) => { {rows - .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) // **Fixed slicing logic** - .map((row) => { - return ( - {/* Fixed tabIndex value */} - {columns.map((column) => { - const value = row[column.id]; - return ( - {/* Fixed key and column.id */} - { - column.format && typeof value === 'number' - ? column.format(value) // **Fixed format function call** - : value - } - - ); - })} - - - - - ); - })} + .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) + .map((row) => ( + + {columns.map((column) => { + const value = row[column.id]; + return ( + + {column.format && typeof value === 'number' ? column.format(value) : value} + + ); + })} + + {/* Placeholder button */} + + + ))} - rowsPerPageOptions={[5, 10, 25, 100]} - component="div" - count={rows.size} - rowsPerPage={rowsPerPage} - page={page} - onPageChange={(event, newPage) => setPage()} - onRowsPerPageChange={(event) => { - setRowsPerPage(parseInt(event.target.value, 5)); - setPage(0); - }} + setPage(newPage)} // Fixed setPage call + onRowsPerPageChange={(event) => { + setRowsPerPage(parseInt(event.target.value, 10)); // Fixed parseInt call + setPage(0); + }} + /> - ) -} + ); +}; -export default TableTemplate +export default TableTemplate; -const StyledTableCell = styled(TableCell)(({theme}) => ({ +const StyledTableCell = styled(TableCell)(({ theme }) => ({ [`&.${tableCellClasses.head}`]: { backgroundColor: theme.palette.common.black, color: theme.palette.common.white, @@ -75,7 +73,7 @@ const StyledTableCell = styled(TableCell)(({theme}) => ({ }, })); -const StyledTableRow = styled(TableRow)(({theme}) => ({ +const StyledTableRow = styled(TableRow)(({ theme }) => ({ '&:nth-of-type(odd)': { backgroundColor: theme.palette.action.hover, },