products page error fixed

This commit is contained in:
roshangarg 2024-02-26 15:19:20 +05:30
parent 8d79ce8cb0
commit dec255c54a
3 changed files with 9 additions and 9 deletions

View File

@ -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\"",

View File

@ -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",

View File

@ -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 = () => {
<td className="text-start">{product.name}</td>
<td className="text-start">
{product.category !== ""
? product.category
? product.category?.categoryName
: "Category Not selected "}
</td>
<th className="text-start">{product.price}</th>
@ -582,7 +582,7 @@ const Products = () => {
</th>
<td className="text-start">{product.name}</td>
<td className="text-start">
{product.category}
{product.category?.categoryName}
</td>
<th className="text-start">{product.price}</th>
<td className="text-start">