diff --git a/src/components/pages/Category/Components/procard.jsx b/src/components/pages/Category/Components/procard.jsx index 0344878..13e3316 100644 --- a/src/components/pages/Category/Components/procard.jsx +++ b/src/components/pages/Category/Components/procard.jsx @@ -1,6 +1,8 @@ -import React, { useState } from "react"; +import React,{ useState,useEffect,forwardRef,useImperativeHandle } from "react"; import { FiHeart } from "react-icons/fi"; +import { FaHeart } from "react-icons/fa"; import product_card from "../../../../api/Products.json"; +import { fetchResult } from "../../../../services/api/loaded-services"; import { Badge, Card, @@ -21,106 +23,86 @@ import { Productpage } from "../../../../styles/pages/category-styles"; -const Card1 = () => { +const Card1 = forwardRef((props,ref)=> { + const [productData, setproductData] = useState(Array()) + const [wishlist, setwishlist] = useState(true) const [radioPrice, SetRadioPrice] = useState("100to200"); const [radioSize, SetRadioSize] = useState("XXL"); const [toggleHeart, setToggleHeart] = useState(false); - console.log(radioPrice); + + useImperativeHandle(ref, () => ({ + async fetchCategory(cat){ + let pro=[]; + pro = await fetchResult("product",cat) + setproductData(pro) + console.log("product",productData) + console.log("casga",cat) + } + })); + function HeartToggle(id) { setToggleHeart(!toggleHeart); console.log(id); console.log(toggleHeart); } - const listItems1 = product_card.slice(0, 10).map((item, id) => ( - - {item.badge} - - - -
- - {item.product_name} - - - {item.description} - - - ₹{item.newprice} - ₹{item.oldprice} - {item.offer}%OFF - - HeartToggle(id)} - /> - - -
-
- )); - const listItems2 = product_card.slice(10, 20).map((item, id) => ( - - {item.badge} - - - -
- - {item.product_name} - - - {item.description} - - - ₹{item.newprice} - ₹{item.oldprice} - {item.offer}%OFF - - - - -
-
- )); - const listItems3 = product_card.slice(20).map((item, id) => ( - - {item.badge} - - - -
- - {item.product_name} - - - {item.description} - - - ₹{item.newprice} - ₹{item.oldprice} - {item.offer}%OFF - - - - -
-
- )); + // const listItems2 = product_card.slice(10, 20).map((item, id) => ( + // + // {item.badge} + // + // + // + //
+ // + // {item.product_name} + // + // + // {item.description} + // + // + // ₹{item.newprice} + // ₹{item.oldprice} + // {item.offer}%OFF + // + // + // + // + //
+ //
+ // )); + // const listItems3 = product_card.slice(20).map((item, id) => ( + // + // {item.badge} + // + // + // + //
+ // + // {item.product_name} + // + // + // {item.description} + // + // + // ₹{item.newprice} + // ₹{item.oldprice} + // {item.offer}%OFF + // + // + // + // + //
+ //
+ // )); const ShopbyPrice = () => (
@@ -274,20 +256,60 @@ const Card1 = () => { return (
- {listItems1} + {productData.length > 0 && + productData.map((item,id) => ( + + NEW + + + +
+ + {item.name} + + + {item.description} + + + ₹{item.buyingPrice} + ₹{item.originalPrice} + {item.discount}%OFF + + + { + wishlist ? + setwishlist(!wishlist)} /> + : + setwishlist(!wishlist)}/> + } + + {/* HeartToggle(id)} + /> */} + + +
+
+ ))}

Shop by Price

- {listItems2} + {/* {listItems2} */}

Shop by Size

- {listItems3} + {/* {listItems3} */}
); -}; + }); export default Card1; diff --git a/src/components/pages/Category/Components/productCard.jsx b/src/components/pages/Category/Components/productCard.jsx index a3c3bc7..8ffa7c0 100644 --- a/src/components/pages/Category/Components/productCard.jsx +++ b/src/components/pages/Category/Components/productCard.jsx @@ -29,8 +29,7 @@ import { Caro, CartButton, WishlistButton, - Similar, - Productpage + Similar } from "../../../../styles/pages/category-styles"; import { Button } from "../../../../styles/widgets/widgets"; import StarRatings from "react-star-ratings"; @@ -364,7 +363,7 @@ const Card2 = () => { $(this).addClass("active").siblings().removeClass("active"); }); }); - return {listItems}; + return
{listItems}
; }; export default Card2; diff --git a/src/components/pages/Category/Components/sidebarnav.jsx b/src/components/pages/Category/Components/sidebarnav.jsx index 7e6448b..d3d00e1 100644 --- a/src/components/pages/Category/Components/sidebarnav.jsx +++ b/src/components/pages/Category/Components/sidebarnav.jsx @@ -1,12 +1,13 @@ import React, { useState,useEffect} from "react"; import $ from 'jquery'; +import PuffLoader from "react-spinners/PuffLoader"; import { fetchResult } from "../../../../services/api/loaded-services"; import { GoGrabber } from "react-icons/go"; import {AiFillCaretDown,AiOutlinePlus} from 'react-icons/ai'; -import {Links,ListGroup, PageContentWrapper, PriceLink, RadioGroup, SidebarHeading, SidebarWrapper, SizeLink, Toggle, TogglePrice, UnorderedList } from "../../../../styles/pages/category-styles"; +import {Links,ListGroup, PageContentWrapper, PriceLink, RadioGroup, SidebarHeading, SidebarWrapper, SizeLink, Toggle, TogglePrice, UnorderedList,ActiveClass } from "../../../../styles/pages/category-styles"; import { Lora } from "../../../../styles/themes/font-styles"; -const SidebarNav = () => { +const SidebarNav = ({sendCategory}) => { const [caturls, setcaturls] = useState([]); const [subcaturls, setsubcaturls] = useState([]); const [showGadgets, setShowGadgets] = useState({}); @@ -15,18 +16,19 @@ const SidebarNav = () => { const [showSize, setShowSize] = useState(true); const[radioPrice,SetRadioPrice] = useState('₹100 - ₹200'); const[radioSize,SetRadioSize] = useState('S'); - + const [loading, setloading] = useState(true); + const fetchCategories = async () => { let categories = []; categories = await fetchResult("categories"); if (categories === null) categories = []; setcaturls(categories); // console.log(caturls[0].name); - console.log(caturls); + // console.log(caturls); setShowGadgets(data=>{ return {...data,...Array(categories.length).fill(false)} }); - console.log("show",showGadgets); + // console.log("show",showGadgets); }; const fetchSubCategories = async () => { @@ -35,21 +37,38 @@ const SidebarNav = () => { if (subcategories === null) subcategories = []; setsubcaturls([...subcategories]); // console.log(caturls[0].name); - console.log(subcaturls,subcategories); + // console.log(subcaturls,subcategories); }; useEffect(() => { - $('ul li').click(function(){ - $(this).addClass("active").siblings().removeClass("active"); - $(this).siblings().find('li').removeClass('active'); - }); $('div input').click(function(){ $(this).addClass("active").siblings().removeClass("active"); }); fetchCategories(); fetchSubCategories(); + setloading(false); + sendCategory("All"); },[]) + function handleactiveparent(e){ + let cls="" + e.target.classList.forEach(a=>{ + cls="."+a+" " + }) + $(cls).parent("li").removeClass('active'); + $(e.target).parent("li").addClass("active").siblings().removeClass("active"); + } + function handleactivechildren(e,index){ + let cls="" + e.target.classList.forEach(a=>{ + cls="."+a+" " + }) + $(cls).parent("li").removeClass('active'); + console.log(e); + $(e.target).parent("li").addClass("active"); + $("#category_"+index).addClass("active"); + + } return ( -
+
{ showSidebar &&
+