OrderReview.jsx
3.78 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import React from 'react'
import { formatPrice } from '../../utils/formatters'
const OrderReview = ({ orderData, cartItems, onPlaceOrder, loading, onBack }) => {
const subtotal = cartItems.reduce((total, item) => total + (item.price * item.quantity), 0)
const tax = subtotal * 0.1
const total = subtotal + tax
return (
<div className="order-review">
<h2>Review Your Order</h2>
<div className="review-sections">
<div className="review-section">
<div className="section-header">
<h3>Shipping Information</h3>
<button
onClick={() => onBack()}
className="edit-button"
>
Edit
</button>
</div>
<div className="section-content">
<p>
{orderData.shipping.firstName} {orderData.shipping.lastName}
</p>
<p>{orderData.shipping.address}</p>
<p>
{orderData.shipping.city}, {orderData.shipping.state} {orderData.shipping.zipCode}
</p>
<p>{orderData.shipping.country}</p>
<p>Phone: {orderData.shipping.phone}</p>
</div>
</div>
<div className="review-section">
<div className="section-header">
<h3>Payment Method</h3>
<button
onClick={() => onBack()}
className="edit-button"
>
Edit
</button>
</div>
<div className="section-content">
<p>Card ending in {orderData.payment.cardNumber?.slice(-4)}</p>
<p>Name: {orderData.payment.cardName}</p>
<p>Expires: {orderData.payment.expiryDate}</p>
</div>
</div>
<div className="review-section">
<h3>Order Items</h3>
<div className="order-items-review">
{cartItems.map(item => (
<div key={item.product._id} className="review-item">
<div className="item-image">
<img
src={item.product.image}
alt={item.product.name}
onError={(e) => {
e.target.src = '/placeholder-image.jpg'
}}
/>
</div>
<div className="item-details">
<h4>{item.product.name}</h4>
<p>Quantity: {item.quantity}</p>
</div>
<div className="item-price">
{formatPrice(item.price * item.quantity)}
</div>
</div>
))}
</div>
</div>
<div className="review-section">
<h3>Order Summary</h3>
<div className="order-summary-review">
<div className="summary-row">
<span>Subtotal ({cartItems.length} items):</span>
<span>{formatPrice(subtotal)}</span>
</div>
<div className="summary-row">
<span>Shipping:</span>
<span>Free</span>
</div>
<div className="summary-row">
<span>Tax:</span>
<span>{formatPrice(tax)}</span>
</div>
<div className="summary-row total">
<strong>Total:</strong>
<strong>{formatPrice(total)}</strong>
</div>
</div>
</div>
</div>
<div className="review-actions">
<button
onClick={onBack}
className="back-button"
>
Back
</button>
<button
onClick={onPlaceOrder}
disabled={loading}
className="place-order-button"
>
{loading ? 'Placing Order...' : 'Place Order'}
</button>
</div>
</div>
)
}
export default OrderReview