-
Notifications
You must be signed in to change notification settings - Fork 0
/
OrdersList.jsx
48 lines (46 loc) · 1.39 KB
/
OrdersList.jsx
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
import { useLoaderData } from 'react-router-dom';
import day from 'dayjs';
import advancedFormat from 'dayjs/plugin/advancedFormat';
day.extend(advancedFormat);
const OrdersList = () => {
const { orders, meta } = useLoaderData();
return (
<div className='mt-8'>
<h4 className='mb-4 capitalize'>
total orders : {meta.pagination.total}
</h4>
<div className='overflow-x-auto'>
<table className='table table-zebra'>
{/* head */}
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>Products</th>
<th>Cost</th>
<th className='hidden sm:block'>Date</th>
</tr>
</thead>
<tbody>
{orders.map((order) => {
const id = order.id;
const { name, address, numItemsInCart, orderTotal, createdAt } =
order.attributes;
const date = day(createdAt).format('hh:mm a - MMM Do, YYYY');
return (
<tr key={id}>
<td>{name}</td>
<td>{address}</td>
<td>{numItemsInCart}</td>
<td>{orderTotal}</td>
<td className='hidden sm:block'>{date}</td>
</tr>
);
})}
</tbody>
</table>
</div>
</div>
);
};
export default OrdersList;