puwanath commited on
Commit
45f89d2
·
verified ·
1 Parent(s): ad83dcc

Upload components/RecentOrders.jsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. components/RecentOrders.jsx +66 -0
components/RecentOrders.jsx ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import { Receipt, Clock, User, DollarSign } from 'lucide-react';
3
+
4
+ const RecentOrders = ({ orders }) => {
5
+ const formatPrice = (price) => {
6
+ return new Intl.NumberFormat('th-TH', {
7
+ style: 'currency',
8
+ currency: 'THB'
9
+ }).format(price);
10
+ };
11
+
12
+ const formatDate = (dateString) => {
13
+ const date = new Date(dateString);
14
+ return new Intl.DateTimeFormat('th-TH', {
15
+ day: 'numeric',
16
+ month: 'short',
17
+ hour: '2-digit',
18
+ minute: '2-digit'
19
+ }).format(date);
20
+ };
21
+
22
+ return (
23
+ <div className="bg-white rounded-2xl border border-pos-border p-5">
24
+ <div className="flex items-center justify-between mb-4">
25
+ <h3 className="font-bold text-pos-text">คำสั่งซื้อล่าสุด</h3>
26
+ <span className="bg-primary-50 text-primary-600 px-2 py-1 rounded-lg text-xs font-medium">
27
+ 24 รายการ
28
+ </span>
29
+ </div>
30
+
31
+ <div className="space-y-3">
32
+ {orders.slice(0, 5).map((order) => (
33
+ <div key={order.id} className="flex items-center justify-between p-3 bg-pos-bg rounded-xl hover:bg-primary-50 transition-colors cursor-pointer">
34
+ <div className="flex items-center gap-3">
35
+ <div className="w-10 h-10 bg-primary-100 rounded-full flex items-center justify-center text-primary-600">
36
+ <Receipt className="w-5 h-5" />
37
+ </div>
38
+ <div>
39
+ <p className="font-medium text-pos-text">#{order.id}</p>
40
+ <p className="text-xs text-pos-text-secondary">{formatDate(order.date)}</p>
41
+ </div>
42
+ </div>
43
+ <div className="flex flex-col items-end">
44
+ <p className="font-bold text-pos-text">{formatPrice(order.total)}</p>
45
+ <div className="flex items-center gap-1">
46
+ <span className={`text-xs px-2 py-0.5 rounded-full ${
47
+ order.status === 'completed'
48
+ ? 'bg-success/10 text-success'
49
+ : 'bg-warning/10 text-warning'
50
+ }`}>
51
+ {order.status === 'completed' ? 'สำเร็จ' : 'กำลังดำเนินการ'}
52
+ </span>
53
+ </div>
54
+ </div>
55
+ </div>
56
+ ))}
57
+ </div>
58
+
59
+ <button className="w-full mt-4 py-2 text-primary-600 hover:bg-primary-50 rounded-lg text-sm font-medium transition-colors">
60
+ ดูประวัติทั้งหมด
61
+ </button>
62
+ </div>
63
+ );
64
+ };
65
+
66
+ export default RecentOrders;