Skip to content

Commit 918caf0

Browse files
committed
Refactoring Payments/checkout & shopping cart pages of sprint_01
Using the layout pattern.. say hi!
1 parent afb0828 commit 918caf0

File tree

32 files changed

+5552
-302
lines changed

32 files changed

+5552
-302
lines changed

src/apps/dashboardApp/App.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ export default function DashboardApp() {
4747
<Route index element={<ChaptersTabDetailsTab />} />
4848
<Route path="resources" element={<ChaptersTabResourcesTab />} />
4949
</Route>
50-
<Route path="promotion" element={<PromotionTab />} />
50+
<Route path="promotion">
51+
<Route index element={<PromotionTab />} />
52+
<Route path=":couponId" element={<h1>CouponPage here</h1>} />
53+
</Route>
5154
<Route path="details" element={<DetailsTab />} />
5255
<Route path="settings" element={<SettingsTab />} />
5356
</Route>

src/apps/mainApp/App.css

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,28 @@
1212
height: 100%;
1313
}
1414

15-
/* Signup && login pages */
15+
/* Global classes */
16+
17+
.btn--squared {
18+
padding: 10px;
19+
}
20+
21+
.btn--flatted {
22+
padding: 0.75rem 1.5rem;
23+
border-radius: 0.5rem;
24+
}
25+
26+
figure:hover {
27+
transform: translateY(-3px);
28+
box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1),
29+
0 8px 10px -6px rgb(0 0 0 / 0.1) !important;
30+
transition: 0.2s ease;
31+
}
32+
33+
/*
34+
* Signup && login pages:
35+
*
36+
*/
1637
.signup-page,
1738
.login-page {
1839
display: grid;
@@ -32,21 +53,3 @@
3253
background-repeat: no-repeat;
3354
background-size: 100% 100%;
3455
}
35-
36-
/* Global classes */
37-
38-
.btn--squared {
39-
padding: 10px;
40-
}
41-
42-
.btn--flatted {
43-
padding: 0.75rem 1.5rem;
44-
border-radius: 0.5rem;
45-
}
46-
47-
figure:hover {
48-
transform: translateY(-3px);
49-
box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1),
50-
0 8px 10px -6px rgb(0 0 0 / 0.1) !important;
51-
transition: 0.2s ease;
52-
}

src/apps/mainApp/App.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import TabMessage from "./pages/Profile/Components/TabMessage/TabMessage";
1919
import TabMyReviews from "./pages/Profile/Components/TabMyReviews/TabMyReviews";
2020
import CourseContent from "./pages/CourseContent/CourseContent";
2121
import MentorPage from "./pages/Mentor/MentorPage";
22+
import OrderComplete from "./components/OrderComplete/OrderComplete";
2223

2324
function App() {
2425
return (
@@ -31,9 +32,10 @@ function App() {
3132
<Route index element={<CoursesPage />} />
3233
<Route path=":id" element={<CoursePage />} />
3334
</Route>
34-
<Route path="cart">
35-
<Route index element={<ShoppingCartPage />} />
36-
<Route path="checkout" element={<CheckoutPage />} />
35+
<Route path="cart" element={<ShoppingCartPage />} />
36+
<Route path="payment/checkout">
37+
<Route index element={<CheckoutPage />} />
38+
<Route path="done" element={<OrderComplete />} />
3739
</Route>
3840
<Route path="profile" element={<ProfilePage />}>
3941
<Route index element={<TabProfile />} />
@@ -57,7 +59,7 @@ function App() {
5759
function AppDev() {
5860
return (
5961
<>
60-
{/* <Dev /> */}
62+
<Dev />
6163
<App />
6264
</>
6365
);

src/apps/mainApp/components/Navbar/Navbar.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export default function Navbar() {
1919
<Logo />
2020
<ul className="navbar-items">
2121
<li>
22-
<NavLink to={"/courses"}>courses</NavLink>
22+
<NavLink to={"/courses"} end>
23+
courses
24+
</NavLink>
2325
</li>
2426
<li className="form-item">
2527
<form onSubmit={submitHandler}>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.order-complete {
2+
display: flex;
3+
align-items: center;
4+
justify-content: center;
5+
}
6+
7+
.order-complete-content {
8+
text-align: center;
9+
margin-block: var(--main-margin);
10+
}
11+
12+
.order-complete h1 {
13+
margin-block: 1rem 0.5rem;
14+
}
15+
16+
.order-complete img {
17+
width: unset;
18+
height: unset;
19+
margin-inline: auto;
20+
display: block;
21+
}
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
import React from "react";
22
import "./OrderComplete.css";
3+
import done from "../../../../assets/done.png";
34

45
export default function OrderComplete() {
5-
return <div className="order-complete">index</div>;
6+
return (
7+
<div className="order-complete">
8+
<div className="container">
9+
<div className="order-complete-content">
10+
<img alt="order-complete" src={done} />
11+
<h1>Order Complete</h1>
12+
<h3>You Will Receive a confirmation email soon! </h3>
13+
</div>
14+
</div>
15+
</div>
16+
);
617
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Shopping && Payment/checkout pages
3+
*
4+
*/
5+
.layout-cart h1 {
6+
color: #333;
7+
margin-block: 2rem;
8+
}
9+
10+
.layout-cart h3 {
11+
padding-bottom: 0.5rem;
12+
border-bottom: 1px solid rgb(211, 211, 211);
13+
margin-bottom: 1.25rem;
14+
color: #333;
15+
font-size: 1rem;
16+
}
17+
18+
.layout-cart p {
19+
color: #334155;
20+
}
21+
.layout-cart-body {
22+
margin-block: 2rem;
23+
display: grid;
24+
grid-template-columns: 3fr 1fr;
25+
gap: 2rem;
26+
}
27+
28+
.layout-cart-content > * {
29+
margin-bottom: var(--main-margin);
30+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from "react";
2+
import "./Cart.css";
3+
import Details from "./Details/Details";
4+
5+
export default function LayoutCart({
6+
children,
7+
title = "Shopping Cart",
8+
isCheckoutPage = false,
9+
}) {
10+
return (
11+
<div className="layout-cart">
12+
<div className="container">
13+
<h1>{title}</h1>
14+
<div className="layout-cart-body">
15+
<div className="layout-cart-content">{children}</div>
16+
<aside className="aside">
17+
<Details isCheckoutPage={isCheckoutPage} />
18+
</aside>
19+
</div>
20+
</div>
21+
</div>
22+
);
23+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.layout-cart .details-aside h3 {
2+
margin-bottom: 0.5rem;
3+
border-bottom-color: transparent;
4+
font-size: 1.25rem;
5+
}
6+
7+
.layout-cart .details-aside .orderDetails {
8+
border: thin solid rgb(211, 211, 211);
9+
}
10+
11+
.layout-cart .details-aside .orderDetails .orderPrice .num {
12+
color: #0f172a;
13+
font-weight: bolder;
14+
}
15+
16+
.layout-cart .details-aside .btn {
17+
padding: 0.75rem;
18+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import React, { useState } from "react";
2+
import "./Details.css";
3+
import { Link, useNavigate } from "react-router-dom";
4+
5+
export default function Details({ isCheckoutPage = false }) {
6+
const navigate = useNavigate();
7+
const [isPaymentCompleted, setIsPaymentCompleted] = useState(false);
8+
9+
function completeHandler() {
10+
setIsPaymentCompleted(true);
11+
navigate("done");
12+
}
13+
14+
return (
15+
<aside className="details-aside">
16+
<h3>Order Details</h3>
17+
<div className="orderDetails p-3 text-black mb-4">
18+
<div className="orderPrice d-flex justify-content-between my-2">
19+
<span>Price</span>
20+
<span className="num">$300.00</span>
21+
</div>
22+
<div className="orderPrice d-flex justify-content-between my-2">
23+
<span>Discount</span>
24+
<span className="num">-$10.00</span>
25+
</div>
26+
<div className="orderPrice d-flex justify-content-between my-2">
27+
<span>Tax</span>
28+
<span className="num">$20.00</span>
29+
</div>
30+
<div className="orderPrice d-flex justify-content-between my-3">
31+
<span className=" fw-bolder fs-5">Total</span>
32+
<span className="num fs-5">$00.00</span>
33+
</div>
34+
</div>
35+
36+
{isCheckoutPage ? (
37+
<button
38+
onClick={completeHandler}
39+
className="text-center w-100 m-auto d-block btn px-5 rounded-3 btn-danger"
40+
>
41+
Complete Checkout
42+
</button>
43+
) : (
44+
<Link
45+
className="text-center w-100 m-auto d-block btn px-5 rounded-3 btn-dark"
46+
to={"/payment/checkout"}
47+
>
48+
Proceed to Checkout
49+
</Link>
50+
)}
51+
</aside>
52+
);
53+
}

0 commit comments

Comments
 (0)