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

overlay added #83

Merged
merged 2 commits into from
Jul 20, 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
62 changes: 34 additions & 28 deletions src/components/pages/Category/Components/procard.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React,{ useState,useEffect } from "react";
import React, { useState, useEffect } from "react";
import { FiHeart } from "react-icons/fi";
import { FaHeart } from "react-icons/fa";
import { AiOutlineShoppingCart } from "react-icons/ai";
Expand Down Expand Up @@ -40,6 +40,7 @@ const Card1 = () => {
const [loading, setloading] = useState(true);
const [noMore,setNoMore] = useState(false);
// const [toggleHeart, setToggleHeart] = useState(false);

async function fetchCategory(cat, p){
let pro=[];
pro = await fetchResult("productcategory",cat,p)
Expand Down Expand Up @@ -71,11 +72,13 @@ const Card1 = () => {
setproductData([...data])
}
setPage(p+1)

setloading(false);
console.log("product",productData)
console.log("casga",subcat)
}
console.log("product", productData)
console.log("casga", subcat)
}
const params = useParams();

console.log("paramsslug",params.slug);
console.log("paramssubslug",params.subslug);

Expand All @@ -99,51 +102,52 @@ const Card1 = () => {
if(wishlistproduct.description.includes("doesn't")){
toast("Already removed from Wishlist!",{
style:{backgroundColor:`${LightShade}`,color:'white',width:'60%'}

});
}
else if(wishlistproduct.description.includes("successfully")){
toast("Removed from Wishlist!",{
style:{backgroundColor:'plum',color:'white',width:'50%'}
else if (wishlistproduct.description.includes("successfully")) {
toast("Removed from Wishlist!", {
style: { backgroundColor: 'plum', color: 'white', width: '50%' }
});
let a=item.find(e => e.id === id)
let a = item.find(e => e.id === id)
a.wishlist = !a.wishlist;
console.log("uytdfgh",item)
console.log("uytdfgh", item)
setproductData([...item])
}else if(wishlistproduct !==null && wishlistproduct.description==="" && wishlistproduct.customer===null){
history.push("/login");
}
else{
toast.error("Error in Removing from Wishlist",{
style:{backgroundColor:'plum',color:'white',width:'50%'}
else {
toast.error("Error in Removing from Wishlist", {
style: { backgroundColor: 'plum', color: 'white', width: '50%' }
});
}
}
else{
wishlistproduct = await fetchResult("addtowishlist",id)
console.log("wishlistproduct",wishlistproduct)
if(wishlistproduct.description.includes("Already")){
toast("Already in Wishlist!",{
style:{backgroundColor:`${LightShade}`,color:'white',width:'60%'}
else {
wishlistproduct = await fetchResult("addtowishlist", id)
console.log("wishlistproduct", wishlistproduct)
if (wishlistproduct.description.includes("Already")) {
toast("Already in Wishlist!", {
style: { backgroundColor: `${LightShade}`, color: 'white', width: '60%' }
});
}
else if(wishlistproduct.description.includes("created")){
toast("Added To Wishlist!",{
style:{backgroundColor:'plum',color:'white',width:'50%'}
else if (wishlistproduct.description.includes("created")) {
toast("Added To Wishlist!", {
style: { backgroundColor: 'plum', color: 'white', width: '50%' }
});
let a=item.find(e => e.id === id)
let a = item.find(e => e.id === id)
a.wishlist = !a.wishlist;
console.log("uytdfgh",item)
console.log("uytdfgh", item)
setproductData([...item])
}else if(wishlistproduct !==null && wishlistproduct.description==="" && wishlistproduct.customer===null){
history.push("/login");
}
else{
toast.error("Error in Adding to Wishlist",{
style:{backgroundColor:'plum',color:'white',width:'50%'}
else {
toast.error("Error in Adding to Wishlist", {
style: { backgroundColor: 'plum', color: 'white', width: '50%' }
});
}
}

}

const showmore = () => {
Expand Down Expand Up @@ -305,6 +309,7 @@ const Card1 = () => {
);
return (
<>

<ToastContainer
position="bottom-center"
autoClose={5000}
Expand Down Expand Up @@ -383,7 +388,8 @@ const Card1 = () => {

</Productpage>
}</>

);
};
};

export default Card1;
13 changes: 8 additions & 5 deletions src/components/pages/Category/Components/viewproduct.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, {useState,useEffect} from 'react';
import {FaArrowCircleUp} from 'react-icons/fa';
import React, { useState, useEffect } from 'react';
import { FaArrowCircleUp } from 'react-icons/fa';
import Card2 from "../../../utils/layout/productCard"
// import SidebarNav from "./sidebarnav"
import {TopButton} from "../../../../styles/pages/category-styles"
import { TopButton } from "../../../../styles/pages/category-styles"
import { useParams } from "react-router-dom";
import { fetchResult } from '../../../../services/api/loaded-services';
const Products = () => {

const [visible, setVisible] = useState(false)
const [data, setData]= useState({})
const [loading,setLoading]= useState(true)
Expand All @@ -24,11 +25,13 @@ const Products = () => {
top: 0,
behavior: 'smooth'
});

};
const params = useParams();
useEffect(() => {
console.log("proparams",params.id);
console.log("proparams", params.id);
async function fetchdata() {

let res = await fetchResult("singleproduct",params.id)
setData(res);
setLoading(false);
Expand All @@ -46,5 +49,5 @@ const Products = () => {
</TopButton>
</div> );
}

export default Products;
83 changes: 71 additions & 12 deletions src/components/pages/offer-page/components/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ import Loading from "../../../utils/loader";
import { Link, useParams } from "react-router-dom";
import { TiMediaPlayOutline } from "react-icons/ti";
import { Container, Row } from "react-bootstrap";
import { Text } from "../../../../styles/widgets/widgets";
import { Text, Button } from "../../../../styles/widgets/widgets";
import { fetchResult } from "../../../../services/api/loaded-services";
import { ApiPostService } from "../../../../services/api/api-services";
import { CardImg } from "../../../../styles/pages/home-page";
import { Column } from "../../../../styles/pages/offer-page";
import { Column, Overlay, ImgOverlay } from "../../../../styles/pages/offer-page";
import { HiHeart } from 'react-icons/hi'
import { toast } from "react-toastify";
import { LightShade } from "../../../../styles/themes/color-theme";
import { retriveDetails } from "../../../../services/storage/details";


const Layout = () => {
let history = useHistory();
Expand Down Expand Up @@ -39,18 +44,50 @@ const Layout = () => {
setSaleProducts(home.offers[index]);
}
getProducts();
}, []);
console.log("sale", saleProducts)
}, [saleProducts]);

const AddWishlist = async (pid, index) => {
let user = await retriveDetails()
let res = await ApiPostService(process.env.REACT_APP_ADD_WISHLIST_URL, {
"customer": user.id,
"product": pid
})
if (res.sucess) {
setSaleProducts()
console.log("before", saleProducts)
setSaleProducts(prev => ({
...prev,
[saleProducts.values[index].wishlist]: true
}))
console.log("after", saleProducts)
}
}

const RemoveWishlist = async (pid) => {
let user = await retriveDetails()
let res = await ApiPostService(process.env.REACT_APP_REMOVE_WISHLIST_URL + "/" + user.id + "/" + pid + "/")
if (res.sucess) {
setSaleProducts()
console.log("before", saleProducts)
setSaleProducts(prev => ({
...prev,
[saleProducts.values[index].wishlist]: false
}))
console.log("after", saleProducts)
}
}
return (
<>

{saleProducts ? (
<>
<Text align="center" style={{ backgroundColor: "#edeaee" }}>
Purple Mart's {saleProducts.name}
</Text>
<Container className="mt-5">
<Row>
{saleProducts.values.map((item) => (
{saleProducts.values.map((item, i) => (
<Column
primary="true"
lg="2"
Expand All @@ -61,14 +98,36 @@ const Layout = () => {
data-bs-placement="right"
title={item.name}
>
<CardImg
imgheight="230px"
className="mb-3"
src={item.image}
alt="Category"
width="100%"
onClick={() => history.push(`/products/${item.id}`)}
/>
<ImgOverlay>
<CardImg
imgheight="230px"
className="mb-3"
src={item.image}
alt="Category"
width="100%"
onClick={() => history.push(`/products/${item.id}`)}
/>
<Overlay>
{
!item.wishlist ?
<Button onClick={() => AddWishlist(item.id, i)}>
<span style={{ fontSize: '.75rem' }} >
Add to wishlist
<HiHeart size="18" className="ml-2 mb-1" />
</span>
</Button>
:

<Button onClick={() => RemoveWishlist(item.id, i)}>
<span style={{ fontSize: '.8rem' }} >
Remove
<HiHeart size="18" className="ml-2 mb-1" />
</span>
</Button>
}
</Overlay>

</ImgOverlay>
<Row className="mx-1">
<Text
primary="true"
Expand Down
Loading