OrderSummary.jsx
2.33 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
import React from 'react'
import { formatDate, formatPrice } from '../../utils/formatters'
const OrderSummary = ({ order }) => {
const getStatusColor = (status) => {
const statusColors = {
pending: '#ffc107',
confirmed: '#17a2b8',
shipped: '#007bff',
delivered: '#28a745',
cancelled: '#dc3545'
}
return statusColors[status] || '#6c757d'
}
return (
<div className="order-summary">
<div className="order-header">
<div className="order-info">
<h3>Order #{order.orderNumber}</h3>
<p>Placed on {formatDate(order.createdAt)}</p>
</div>
<div className="order-status">
<span
className="status-badge"
style={{ backgroundColor: getStatusColor(order.status) }}
>
{order.status.charAt(0).toUpperCase() + order.status.slice(1)}
</span>
</div>
</div>
<div className="order-items">
<h4>Items ({order.items.length})</h4>
{order.items.map(item => (
<div key={item._id} className="order-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">
<h5>{item.product.name}</h5>
<p>Quantity: {item.quantity}</p>
<p>Price: {formatPrice(item.price)}</p>
</div>
<div className="item-total">
{formatPrice(item.price * item.quantity)}
</div>
</div>
))}
</div>
<div className="order-totals">
<div className="total-row">
<span>Subtotal:</span>
<span>{formatPrice(order.subtotal)}</span>
</div>
<div className="total-row">
<span>Shipping:</span>
<span>{formatPrice(order.shipping)}</span>
</div>
<div className="total-row">
<span>Tax:</span>
<span>{formatPrice(order.tax)}</span>
</div>
<div className="total-row grand-total">
<span>Total:</span>
<span>{formatPrice(order.total)}</span>
</div>
</div>
</div>
)
}
export default OrderSummary