|
| 1 | +import React, { useState } from 'react'; |
| 2 | +import { MoreVertical, Search, Filter } from 'lucide-react'; |
| 3 | + |
| 4 | +// Sahte (mock) sipariş verisi |
| 5 | +const allOrdersData = [ |
| 6 | + { id: '#1256', customer: 'Terry Franci', date: 'Oct 25, 2025', total: '$2399.00', status: 'Delivered' }, |
| 7 | + { id: '#1257', customer: 'Alena Franci', date: 'Oct 25, 2025', total: '$879.00', status: 'Pending' }, |
| 8 | + { id: '#1258', customer: 'Brandon Philips', date: 'Oct 24, 2025', total: '$1869.00', status: 'Delivered' }, |
| 9 | + { id: '#1259', customer: 'Jocelyn Kenter', date: 'Oct 24, 2025', total: '$1699.00', status: 'Canceled' }, |
| 10 | + { id: '#1260', customer: 'Mara Vit', date: 'Oct 23, 2025', total: '$240.00', status: 'Delivered' }, |
| 11 | + { id: '#1261', customer: 'Terry Franci', date: 'Oct 22, 2025', total: '$55.00', status: 'Delivered' }, |
| 12 | + { id: '#1262', customer: 'Brandon Philips', date: 'Oct 21, 2025', total: '$320.00', status: 'Pending' }, |
| 13 | + { id: '#1263', customer: 'Alena Franci', date: 'Oct 20, 2025', total: '$199.90', status: 'Delivered' }, |
| 14 | +]; |
| 15 | + |
| 16 | +const statusColors = { |
| 17 | + Delivered: 'bg-green-100 text-green-700 dark:bg-green-500/20 dark:text-green-400', |
| 18 | + Pending: 'bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-400', |
| 19 | + Canceled: 'bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-400', |
| 20 | +}; |
| 21 | + |
| 22 | +const filterTabs = ['All', 'Delivered', 'Pending', 'Canceled']; |
| 23 | + |
| 24 | +function OrdersTable({ isDark }) { |
| 25 | + const [activeTab, setActiveTab] = useState('All'); |
| 26 | + |
| 27 | + const filteredOrders = allOrdersData.filter(order => |
| 28 | + activeTab === 'All' ? true : order.status === activeTab |
| 29 | + ); |
| 30 | + |
| 31 | + return ( |
| 32 | + <div className={`p-6 rounded-xl border shadow-sm transition-colors duration-300 ${ |
| 33 | + isDark |
| 34 | + ? 'bg-slate-800 border-slate-700/50' |
| 35 | + : 'bg-white border-slate-200/50' |
| 36 | + }`}> |
| 37 | + {/* Tablo Başlığı ve Filtreler */} |
| 38 | + <div className="flex flex-col items-center justify-between gap-4 mb-4 md:flex-row"> |
| 39 | + <div className="flex items-center space-x-2"> |
| 40 | + {filterTabs.map(tab => ( |
| 41 | + <button |
| 42 | + key={tab} |
| 43 | + onClick={() => setActiveTab(tab)} |
| 44 | + className={`px-3 py-1.5 text-sm font-semibold rounded-md transition-colors ${ |
| 45 | + activeTab === tab |
| 46 | + ? `text-indigo-600 ${isDark ? 'bg-indigo-500/20' : 'bg-indigo-50'}` |
| 47 | + : `${isDark ? 'text-slate-400 hover:text-slate-200' : 'text-slate-500 hover:text-slate-800'}` |
| 48 | + }`} |
| 49 | + > |
| 50 | + {tab} |
| 51 | + </button> |
| 52 | + ))} |
| 53 | + </div> |
| 54 | + <div className="flex items-center w-full space-x-2 md:w-auto"> |
| 55 | + <div className="relative w-full md:w-64"> |
| 56 | + <Search className={`w-4 h-4 absolute left-3 top-1/2 transform -translate-y-1/2 ${isDark ? 'text-slate-500' : 'text-slate-400'}`} /> |
| 57 | + <input |
| 58 | + type="text" |
| 59 | + placeholder="Search order ID or customer..." |
| 60 | + className={`w-full pl-10 pr-4 py-2 text-sm rounded-xl focus:outline-none focus:ring-2 focus:ring-indigo-500 transition-all ${ |
| 61 | + isDark |
| 62 | + ? 'bg-slate-700 border-slate-600 text-white placeholder-slate-500' |
| 63 | + : 'bg-slate-100 border-transparent text-slate-800 placeholder-slate-400' |
| 64 | + }`} |
| 65 | + /> |
| 66 | + </div> |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + |
| 70 | + {/* Sipariş Listesi - Tablo */} |
| 71 | + <div className="overflow-x-auto"> |
| 72 | + <div className="min-w-[700px]"> |
| 73 | + {/* Tablo Başlıkları */} |
| 74 | + <div className={`grid grid-cols-12 gap-4 px-4 py-2 text-xs font-semibold uppercase ${isDark ? 'text-slate-400' : 'text-slate-500'}`}> |
| 75 | + <div className="col-span-2">Order ID</div> |
| 76 | + <div className="col-span-3">Customer</div> |
| 77 | + <div className="col-span-3">Date</div> |
| 78 | + <div className="col-span-2">Total</div> |
| 79 | + <div className="col-span-2 text-right">Status</div> |
| 80 | + </div> |
| 81 | + |
| 82 | + {/* Sipariş Öğeleri */} |
| 83 | + {filteredOrders.map((order) => ( |
| 84 | + <div key={order.id} className={`grid grid-cols-12 gap-4 items-center p-4 rounded-lg transition-colors text-sm ${isDark ? 'hover:bg-slate-700/50 text-slate-300' : 'hover:bg-slate-50 text-slate-700'}`}> |
| 85 | + |
| 86 | + {/* Order ID */} |
| 87 | + <div className={`col-span-2 font-semibold ${isDark ? 'text-white' : 'text-slate-800'}`}>{order.id}</div> |
| 88 | + |
| 89 | + {/* Customer */} |
| 90 | + <div className="col-span-3">{order.customer}</div> |
| 91 | + |
| 92 | + {/* Date */} |
| 93 | + <div className="col-span-3">{order.date}</div> |
| 94 | + |
| 95 | + {/* Total */} |
| 96 | + <div className={`col-span-2 font-medium ${isDark ? 'text-slate-200' : 'text-slate-600'}`}>{order.total}</div> |
| 97 | + |
| 98 | + {/* Status */} |
| 99 | + <div className="flex justify-end col-span-2"> |
| 100 | + <span className={`px-2 py-0.5 text-xs font-semibold rounded-full ${statusColors[order.status]}`}> |
| 101 | + {order.status} |
| 102 | + </span> |
| 103 | + </div> |
| 104 | + </div> |
| 105 | + ))} |
| 106 | + </div> |
| 107 | + </div> |
| 108 | + |
| 109 | + {/* Sayfalama (Pagination) */} |
| 110 | + <div className="flex items-center justify-between pt-4 mt-4 border-t"> |
| 111 | + <span className={`text-sm ${isDark ? 'text-slate-400' : 'text-slate-600'}`}> |
| 112 | + Showing {filteredOrders.length} of {allOrdersData.length} orders |
| 113 | + </span> |
| 114 | + <div className="flex items-center space-x-1"> |
| 115 | + <button className={`px-2.5 py-1 text-sm rounded-md ${isDark ? 'text-slate-500' : 'text-slate-400'}`}>Previous</button> |
| 116 | + <button className={`px-2.5 py-1 text-sm rounded-md ${isDark ? 'bg-slate-700 text-white' : 'bg-indigo-600 text-white'}`}>1</button> |
| 117 | + <button className={`px-2.5 py-1 text-sm rounded-md ${isDark ? 'text-slate-300 hover:bg-slate-700' : 'text-slate-600 hover:bg-slate-100'}`}>Next</button> |
| 118 | + </div> |
| 119 | + </div> |
| 120 | + </div> |
| 121 | + ); |
| 122 | +} |
| 123 | + |
| 124 | +export default OrdersTable; |
0 commit comments