Skip to content

Commit e8cbde0

Browse files
committed
Checkout in progress
1 parent 914c115 commit e8cbde0

File tree

4 files changed

+137
-7
lines changed

4 files changed

+137
-7
lines changed

src/assets/scss/pages/_checkout.scss

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
.checkout-page {
2+
min-height: calc(100vh - 120px);
3+
margin-top: 100px;
4+
.container {
5+
max-width: 960px;
6+
margin: 0 auto;
7+
padding: 0 32px;
8+
display: flex;
9+
.order-details {
10+
flex-grow: 1;
11+
}
12+
.order-summary {
13+
flex-basis: 300px;
14+
}
15+
}
16+
}
17+
18+
.timeline {
19+
text-align: center;
20+
li {
21+
display: inline-block;
22+
border-bottom: 2px solid $gray-eighty;
23+
cursor: pointer;
24+
h2 {
25+
padding: 16px 32px;
26+
text-align: center;
27+
font-size: 16px;
28+
}
29+
&.active {
30+
color: $primary-green;
31+
border-bottom-color: $primary-green;
32+
}
33+
}
34+
}
35+
.order-details {
36+
padding: 24px 0;
37+
}
38+
39+
.order-summary {
40+
padding: 0 24px 24px 24px;
41+
background: $white;
42+
margin: 24px 0;
43+
border-radius: 6px;
44+
h2 {
45+
padding: 16px;
46+
}
47+
.cart-items {
48+
width: 300px;
49+
max-height: 256px;
50+
overflow-y: auto;
51+
}
52+
.total-breakup {
53+
border-top: 1px solid $gray-dark-bg;
54+
padding-top: 24px;
55+
margin-top: 16px;
56+
li {
57+
display: flex;
58+
justify-content: space-between;
59+
margin-bottom: 4px;
60+
h2 {
61+
padding: 16px 0;
62+
}
63+
}
64+
}
65+
}
File renamed without changes.

src/pages/checkout.jsx

Lines changed: 71 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,77 @@
1-
import React from "react";
1+
import React, { useContext } from "react";
2+
import { useHistory } from "react-router-dom";
3+
import classNames from "classnames";
4+
import {
5+
CartStateContext,
6+
CartDispatchContext,
7+
removeFromCart,
8+
toggleCartPopup
9+
} from "contexts/cart";
210

311
const Checkout = () => {
12+
const { items } = useContext(CartStateContext);
413
return (
5-
<div>
6-
<h1>Checkout Page</h1>
7-
<div>Contents</div>
14+
<div className="checkout-page">
15+
<div className="container">
16+
<div className="order-details">
17+
<ul className="timeline">
18+
<li className="done">
19+
<h2>Shipping</h2>
20+
</li>
21+
<li className="active">
22+
<h2>Payment</h2>
23+
</li>
24+
<li>
25+
<h2>Review</h2>
26+
</li>
27+
</ul>
28+
</div>
29+
<div className="order-summary">
30+
<h2>Summary</h2>
31+
<ul className="cart-items">
32+
{items.map((product) => {
33+
return (
34+
<li className="cart-item" key={product.name}>
35+
<img className="product-image" src={product.image} />
36+
<div className="product-info">
37+
<p className="product-name">{product.name}</p>
38+
<p className="product-price">{product.price}</p>
39+
</div>
40+
<div className="product-total">
41+
<p className="quantity">
42+
{`${product.quantity} ${
43+
product.quantity > 1 ? "Nos." : "No."
44+
}`}
45+
</p>
46+
<p className="amount">{product.quantity * product.price}</p>
47+
</div>
48+
</li>
49+
);
50+
})}
51+
</ul>
52+
53+
<ul className="total-breakup">
54+
<li>
55+
<p>Subtotal</p>
56+
<p>5000</p>
57+
</li>
58+
<li>
59+
<p>Tax</p>
60+
<p>5000</p>
61+
</li>
62+
<li>
63+
<p>Shipping</p>
64+
<p>5000</p>
65+
</li>
66+
<li>
67+
<h2>Total</h2>
68+
<h2>5000</h2>
69+
</li>
70+
</ul>
71+
</div>
72+
</div>
873
</div>
974
);
10-
}
75+
};
1176

12-
export default Checkout;
77+
export default Checkout;

src/pages/home.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState, useContext } from "react";
1+
import React, { useEffect, useContext } from "react";
22
import ProductCard from "components/Product";
33
import {
44
ProductsStateContext,

0 commit comments

Comments
 (0)