Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nivetha dev product page #60

Merged
merged 3 commits into from
Jul 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
216 changes: 119 additions & 97 deletions src/components/pages/Category/Components/procard.jsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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) => (
<Card className="col-xs-6 col-md-4 col-lg-2" key={id}>
<Badge Status={item.badge}>{item.badge}</Badge>
<a href="/products">
<CardImg
alt="Card image"
className="card-img-top"
variant="top"
src={item.thumb}
/>
</a>
<div className="card-block">
<CardProductName href="/products" className="card-title">
{item.product_name}
</CardProductName>
<CardProductDescription className="card-text">
{item.description}
</CardProductDescription>
<CardProductBottomDetails className="product-bottom-details">
₹{item.newprice}
<CardProductOldprice>₹{item.oldprice}</CardProductOldprice>
<CardProductOffer>{item.offer}%OFF</CardProductOffer>
<CardWishlist id={id} href="">
<FiHeart
className={toggleHeart ? "heart active" : "heart"}
onClick={() => HeartToggle(id)}
/>
</CardWishlist>
</CardProductBottomDetails>
</div>
</Card>
));
const listItems2 = product_card.slice(10, 20).map((item, id) => (
<Card className="col-xs-6 col-md-4 col-lg-2" key={id}>
<Badge Status={item.badge}>{item.badge}</Badge>
<a href="/products">
<CardImg
alt="Card image"
className="card-img-top"
variant="top"
src={item.thumb}
/>
</a>
<div className="card-block">
<CardProductName href="/products" className="card-title">
{item.product_name}
</CardProductName>
<CardProductDescription className="card-text">
{item.description}
</CardProductDescription>
<CardProductBottomDetails className="product-bottom-details">
₹{item.newprice}
<CardProductOldprice>₹{item.oldprice}</CardProductOldprice>
<CardProductOffer>{item.offer}%OFF</CardProductOffer>
<CardWishlist href="">
<FiHeart />
</CardWishlist>
</CardProductBottomDetails>
</div>
</Card>
));
const listItems3 = product_card.slice(20).map((item, id) => (
<Card className="col-xs-6 col-md-4 col-lg-2" key={id}>
<Badge Status={item.badge}>{item.badge}</Badge>
<a href="/products">
<CardImg
alt="Card image"
className="card-img-top"
variant="top"
src={item.thumb}
/>
</a>
<div className="card-block">
<CardProductName href="/products" className="card-title">
{item.product_name}
</CardProductName>
<CardProductDescription className="card-text">
{item.description}
</CardProductDescription>
<CardProductBottomDetails className="product-bottom-details">
₹{item.newprice}
<CardProductOldprice>₹{item.oldprice}</CardProductOldprice>
<CardProductOffer>{item.offer}%OFF</CardProductOffer>
<CardWishlist href="">
<FiHeart />
</CardWishlist>
</CardProductBottomDetails>
</div>
</Card>
));
// const listItems2 = product_card.slice(10, 20).map((item, id) => (
// <Card className="col-xs-6 col-md-4 col-lg-2" key={id}>
// <Badge Status={item.badge}>{item.badge}</Badge>
// <a href="/products">
// <CardImg
// alt="Card image"
// className="card-img-top"
// variant="top"
// src={item.thumb}
// />
// </a>
// <div className="card-block">
// <CardProductName href="/products" className="card-title">
// {item.product_name}
// </CardProductName>
// <CardProductDescription className="card-text">
// {item.description}
// </CardProductDescription>
// <CardProductBottomDetails className="product-bottom-details">
// ₹{item.newprice}
// <CardProductOldprice>₹{item.oldprice}</CardProductOldprice>
// <CardProductOffer>{item.offer}%OFF</CardProductOffer>
// <CardWishlist href="">
// <FiHeart />
// </CardWishlist>
// </CardProductBottomDetails>
// </div>
// </Card>
// ));
// const listItems3 = product_card.slice(20).map((item, id) => (
// <Card className="col-xs-6 col-md-4 col-lg-2" key={id}>
// <Badge Status={item.badge}>{item.badge}</Badge>
// <a href="/products">
// <CardImg
// alt="Card image"
// className="card-img-top"
// variant="top"
// src={item.thumb}
// />
// </a>
// <div className="card-block">
// <CardProductName href="/products" className="card-title">
// {item.product_name}
// </CardProductName>
// <CardProductDescription className="card-text">
// {item.description}
// </CardProductDescription>
// <CardProductBottomDetails className="product-bottom-details">
// ₹{item.newprice}
// <CardProductOldprice>₹{item.oldprice}</CardProductOldprice>
// <CardProductOffer>{item.offer}%OFF</CardProductOffer>
// <CardWishlist href="">
// <FiHeart />
// </CardWishlist>
// </CardProductBottomDetails>
// </div>
// </Card>
// ));
const ShopbyPrice = () => (
<div style={{ boxSizing: "border-box", margin: "0 -5px" }} className="row">
<Shopcol className="col-xs-12 col-md-4 col-lg-2">
Expand Down Expand Up @@ -274,20 +256,60 @@ const Card1 = () => {
return (
<Productpage className="container">
<div className="row">
{listItems1}
{productData.length > 0 &&
productData.map((item,id) => (
<Card className="col-xs-6 col-md-4 col-lg-2" key={id}>
<Badge Status={item.badge}>NEW</Badge>
<a href="/products">
<CardImg
alt="Card image"
className="card-img-top"
variant="top"
src={item.image}
/>
</a>
<div className="card-block">
<CardProductName href="/products" className="card-title">
{item.name}
</CardProductName>
<CardProductDescription className="card-text">
{item.description}
</CardProductDescription>
<CardProductBottomDetails className="product-bottom-details">
₹{item.buyingPrice}
<CardProductOldprice>₹{item.originalPrice}</CardProductOldprice>
<CardProductOffer>{item.discount}%OFF</CardProductOffer>
<CardWishlist id={id} href="">
<span>
{
wishlist ?
<FiHeart onClick={() => setwishlist(!wishlist)} />
:
<FaHeart onClick={() => setwishlist(!wishlist)}/>
}
</span>
{/* <FiHeart
className={toggleHeart ? "heart active" : "heart"}
onClick={() => HeartToggle(id)}
/> */}
</CardWishlist>
</CardProductBottomDetails>
</div>
</Card>
))}
<Shopbyprice className="row">
<h4>Shop by Price</h4>
<ShopbyPrice />
</Shopbyprice>
{listItems2}
{/* {listItems2} */}
<Shopbysize className="row">
<h4>Shop by Size</h4>
<ShopbySize />
</Shopbysize>
{listItems3}
{/* {listItems3} */}
</div>
</Productpage>
);
};
});

export default Card1;
5 changes: 2 additions & 3 deletions src/components/pages/Category/Components/productCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -364,7 +363,7 @@ const Card2 = () => {
$(this).addClass("active").siblings().removeClass("active");
});
});
return <Productpage>{listItems}</Productpage>;
return <div>{listItems}</div>;
};

export default Card2;
Loading