-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathCheckoutPage.jsx
More file actions
executable file
·62 lines (51 loc) · 1.9 KB
/
Copy pathCheckoutPage.jsx
File metadata and controls
executable file
·62 lines (51 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import axios from 'axios';
import { useState, useEffect } from 'react';
import { OrderSummary } from './OrderSummary';
import { PaymentSummary } from './PaymentSummary';
import './checkout-header.css';
import './CheckoutPage.css';
export function CheckoutPage({ cart, loadCart }) {
const [deliveryOptions, setDeliveryOptions] = useState([]);
const [paymentSummary, setPaymentSummary] = useState(null);
useEffect(() => {
const fetchCheckoutData = async () => {
let response = await axios.get(
'/api/delivery-options?expand=estimatedDeliveryTime'
);
setDeliveryOptions(response.data);
response = await axios.get('/api/payment-summary');
setPaymentSummary(response.data);
};
fetchCheckoutData();
}, [cart]);
return (
<>
<title>Checkout</title>
<div className="checkout-header"
data-testid="checkout-header">
<div className="header-content">
<div className="checkout-header-left-section">
<a href="/">
<img className="logo" src="images/logo.png" />
<img className="mobile-logo" src="images/mobile-logo.png" />
</a>
</div>
<div className="checkout-header-middle-section">
Checkout (<a className="return-to-home-link"
href="/">3 items</a>)
</div>
<div className="checkout-header-right-section">
<img src="images/icons/checkout-lock-icon.png" />
</div>
</div>
</div>
<div className="checkout-page">
<div className="page-title">Review your order</div>
<div className="checkout-grid">
<OrderSummary cart={cart} deliveryOptions={deliveryOptions} loadCart={loadCart} />
<PaymentSummary paymentSummary={paymentSummary} loadCart={loadCart} />
</div>
</div>
</>
);
}