From dec255c54aa3f551c655bd74485ae93cc566d98d Mon Sep 17 00:00:00 2001 From: roshangarg Date: Mon, 26 Feb 2024 15:19:20 +0530 Subject: [PATCH] products page error fixed --- package.json | 5 ++--- src/index.js | 3 ++- src/views/Products/Products.js | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index ffd876b..f56c26e 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,8 @@ "license": "MIT", "author": "The CoreUI Team (https://github.com/orgs/coreui/people)", "scripts": { - "dev": "react-scripts start", - "build": "react-scripts build", - "build:n17": "react-scripts --openssl-legacy-provider build", + "dev": "react-scripts --openssl-legacy-provider start", + "build": "react-scripts --openssl-legacy-provider build", "changelog": "auto-changelog --starting-version 4.1.0 --commit-limit false --hide-credit", "eject": "react-scripts eject", "lint": "eslint \"src/**/*.js\"", diff --git a/src/index.js b/src/index.js index dc32a6f..3cd5764 100644 --- a/src/index.js +++ b/src/index.js @@ -13,7 +13,8 @@ import { cibGmail } from "@coreui/icons"; import { createRoot } from "react-dom/client"; const setupAxios = () => { - axios.defaults.baseURL = "http://localhost:5000"; + // axios.defaults.baseURL = "http://localhost:5000"; + axios.defaults.baseURL = "https://api.smellika.com"; axios.defaults.headers = { "Cache-Control": "no-cache,no-store", diff --git a/src/views/Products/Products.js b/src/views/Products/Products.js index 25106b8..b0bfc9e 100644 --- a/src/views/Products/Products.js +++ b/src/views/Products/Products.js @@ -44,7 +44,6 @@ const Products = () => { }, }) .then((res) => { - console.log(res.data?.product); setProductsData(res.data?.product); setLoading(false); }) @@ -135,7 +134,7 @@ const Products = () => { const result = fuse.search(query); const searchedResult = result.map((result) => result.item); - + console.log(searchedResult); setQueryData(searchedResult); }; useEffect(() => { @@ -148,8 +147,9 @@ const Products = () => { setTimeout(() => { if (filterCategory !== "") { const filteredProducts = productsData.filter( - (product) => product.category === filterCategory + (product) => product.category?.categoryName === filterCategory ); + setFilterData(filteredProducts); } else { // If no category is selected, show all products @@ -480,7 +480,7 @@ const Products = () => { {product.name} {product.category !== "" - ? product.category + ? product.category?.categoryName : "Category Not selected "} ₹{product.price} @@ -582,7 +582,7 @@ const Products = () => { {product.name} - {product.category} + {product.category?.categoryName} ₹{product.price}