File tree

8 files changed

+294
-219
lines changed

8 files changed

+294
-219
lines changed
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ const functions = require("firebase-functions");
77
// response.send("Hello from Firebase!");
88
// });
99

10+
// set env vars: gcloud functions deploy FUNCTION_NAME --set-env-vars FOO=bar , get env vars : process.env.FOO
11+
1012
const express = require("express");
1113
const cors = require("cors");
1214
const stripe = require("stripe")(
13-
"sk_test_51HeTtQImEgmfO9dxsYTv9vHitaqlfq2bW9QkRUzO89Uya2IlzyiJxbMiPY0GNF7sfaKMdWw8GarT0oxCjPZ9jTAf00I0kzR0bU"
15+
process.env.STRIPE_KEY
1416
);
1517

1618
// - App Config
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ const Header = () => {
7171
<p>Electronics</p>
7272
<p>Home</p>
7373
<p>Baby</p>
74-
<p>Toys & Game</p>
75-
<p>Women's Clothing</p>
76-
<p>Men's Clothing</p>
77-
<p>Shoes</p>
74+
7875

7976
</div>
8077
</Drawer>
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ code {
4444
font-size: 1.2rem !important;
4545
}
4646

47+
.image-gallery-thumbnail-image {
48+
width: 60% !important;
49+
}
50+
51+
.image-gallery-image {
52+
width: 80% !important;
53+
}
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import { selectUser } from "../../redux/userSlice";
44
import { useSelector } from "react-redux";
55
import Order from "./../../components/order/Order";
66
import Spinner from "react-bootstrap/Spinner";
7+
import { useNavigate } from "react-router-dom";
8+
import { Result } from "antd";
79

810
const Orders = () => {
911
const [orders, setOrders] = useState([]);
1012
const user = useSelector(selectUser);
13+
const navigate = useNavigate();
1114

1215
useEffect(() => {
1316
let mounted = true;
@@ -28,13 +31,23 @@ const Orders = () => {
2831
});
2932
} else {
3033
setOrders([]);
34+
navigate("/auth");
3135
}
3236
return () => (mounted = false);
33-
}, [user]);
37+
}, [user, navigate]);
3438

3539
return (
3640
<div className="orders">
37-
<h1>Your Orders</h1>
41+
{orders.length > 0 ? (
42+
<h1>Your Orders</h1>
43+
) : (
44+
<Result
45+
status="404"
46+
title="no order found"
47+
subTitle="Oops! you don't have any orders"
48+
/>
49+
)}
50+
3851
<div className="orders__order">
3952
{orders ? (
4053
orders.map((order) => <Order order={order} key={order.id} />)
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const Payment = () => {
102102
</div>
103103
<div className="payment__address">
104104
<p>{user?.name}</p>
105-
<p>22 porana rd </p>
105+
<p>18 Great South Rd </p>
106106
<p>Auckland , New Zealand</p>
107107
</div>
108108
</div>
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,48 @@
11
import React from "react";
22
import { useDis } from "react-redux";
33
import { Button } from "react-bootstrap";
4-
import { useParams,useNavigate } from "react-router-dom";
4+
import { useParams, useNavigate } from "react-router-dom";
55
import { useSelector } from "react-redux";
66
import { selectProduct } from "../../redux/productSelector";
77
import { ReactComponent as AddToCart } from "../../assets/add_shopping_cart.svg";
88
import { addItem } from "../../redux/cartSlice";
99
import ImageGallery from "react-image-gallery";
1010
import "react-image-gallery/styles/css/image-gallery.css";
11-
import { Modal } from 'antd';
12-
import { ExclamationCircleOutlined } from '@ant-design/icons';
11+
import { Modal } from "antd";
12+
import { ExclamationCircleOutlined } from "@ant-design/icons";
13+
import { selectProducts } from "../../redux/productsSlice";
14+
import ProductCard from "../../components/card/ProductCard";
15+
16+
import Slider from "react-slick";
17+
import "slick-carousel/slick/slick.css";
18+
import "slick-carousel/slick/slick-theme.css";
19+
20+
1321

1422
const Product = () => {
23+
//related slider
24+
let slidesToShow;
25+
const width =
26+
window.innerWidth ||
27+
document.documentElement.clientWidth ||
28+
document.body.clientWidth;
29+
if (width > 1024) {
30+
slidesToShow = 7;
31+
} else if (width > 768) {
32+
slidesToShow = 5;
33+
} else if(width === 768) {
34+
slidesToShow = 4;
35+
} else {
36+
slidesToShow = 1;
37+
}
38+
39+
const settings = {
40+
infinite: true,
41+
speed: 500,
42+
slidesToShow,
43+
slidesToScroll: 1,
44+
};
45+
1546
const dis = useDis();
1647
const navigate = useNavigate();
1748
const { productId } = useParams();
@@ -27,6 +58,8 @@ const Product = () => {
2758
gallery,
2859
} = useSelector((state) => selectProduct(state, productId));
2960

61+
const products = useSelector(selectProducts);
62+
3063
const formatedPrice = price.toLocaleString("en-US", {
3164
style: "currency",
3265
currency: "USD",
@@ -43,56 +76,67 @@ const Product = () => {
4376
productId,
4477
active,
4578
})
46-
)
79+
);
4780
Modal.confirm({
48-
title: 'Product added to your cart',
81+
title: "Product added to your cart",
4982
icon: <ExclamationCircleOutlined />,
5083
content: `You've added the ${title} to your cart`,
51-
okText: 'Continue Shopping',
52-
cancelText: 'Proceed to Checkout',
53-
onOk:()=> navigate('/shop'),
54-
onCancel:()=> navigate('/checkout')
84+
okText: "Continue Shopping",
85+
cancelText: "Proceed to Checkout",
86+
onOk: () => navigate("/shop"),
87+
onCancel: () => navigate("/checkout"),
5588
});
56-
}
89+
};
90+
5791
return (
58-
<div className="product">
59-
<div className="product__gallery">
60-
<ImageGallery
61-
items={gallery}
62-
showNav={false}
63-
thumbnailPosition={"left"}
64-
showPlayButton={false}
65-
/>
66-
</div>
67-
<div className="product__description">
68-
<div className="product__description__title">{title}</div>
69-
<div className="product__description__brand">
70-
<span>Brand: </span>
71-
{brand}
92+
<div>
93+
<div className="product">
94+
<div className="product__gallery">
95+
<ImageGallery
96+
items={gallery}
97+
showNav={false}
98+
thumbnailPosition={"left"}
99+
showPlayButton={false}
100+
/>
72101
</div>
73-
<div className="product__description__price">
74-
<span>Price: </span> <span>{formatedPrice}</span>
102+
<div className="product__description">
103+
<div className="product__description__title">{title}</div>
104+
<div className="product__description__brand">
105+
<span>Brand: </span>
106+
{brand}
107+
</div>
108+
<div className="product__description__price">
109+
<span>Price: </span> <span>{formatedPrice}</span>
110+
</div>
111+
<div className="product__description__line" />
112+
<div className="product__description__content">
113+
<ul>
114+
{descriptions.map((el, index) => (
115+
<li key={index}>{el}</li>
116+
))}
117+
</ul>
118+
</div>
75119
</div>
76-
<div className="product__description__line" />
77-
<div className="product__description__content">
78-
<ul>
79-
{descriptions.map((el, index) => (
80-
<li key={index}>{el}</li>
81-
))}
82-
</ul>
120+
<div className="product__cart">
121+
<div className="product__cart__price">{formatedPrice}</div>
122+
<div className="product__cart__button">
123+
<Button
124+
block
125+
className="checkout__subtotal__button"
126+
onClick={handleShopCart}
127+
>
128+
<AddToCart /> <span>Add to Cart</span>
129+
</Button>
130+
</div>
83131
</div>
84132
</div>
85-
<div className="product__cart">
86-
<div className="product__cart__price">{formatedPrice}</div>
87-
<div className="product__cart__button">
88-
<Button
89-
block
90-
className="checkout__subtotal__button"
91-
onClick={handleShopCart}
92-
>
93-
<AddToCart /> <span>Add to Cart</span>
94-
</Button>
95-
</div>
133+
<div className="product__related">
134+
<h3>Inspired by your recent shopping trends</h3>
135+
<Slider {...settings}>
136+
{products.map(({ id, ...props }) => (
137+
<ProductCard key={id} productId={id} {...props} />
138+
))}
139+
</Slider>
96140
</div>
97141
</div>
98142
);
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
.product {
2-
32
@include breakpoint(l) {
4-
53
display: flex;
64
}
75
justify-content: space-between;
@@ -45,7 +43,7 @@
4543
margin: 1.5rem 0;
4644
}
4745

48-
&__content li {
46+
&__content li {
4947
padding-bottom: 1rem;
5048
line-height: 1.5;
5149
}
@@ -65,9 +63,20 @@
6563
margin: 1rem;
6664
padding: 1rem;
6765
&__price {
68-
margin-bottom: 1rem;
69-
color: $text-color-red;
70-
font-weight: 600;
66+
margin-bottom: 1rem;
67+
color: $text-color-red;
68+
font-weight: 600;
69+
}
70+
}
71+
72+
&__related {
73+
margin: 2rem;
74+
@include breakpoint(l) {
75+
margin: 4rem;
76+
}
77+
78+
& > h3 {
79+
color: $secondary-color-dark;
7180
}
7281
}
7382
}

0 commit comments

Comments
 (0)