LatestOrders.js
3.56 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import React, { useState } from 'react';
import clsx from 'clsx';
import moment from 'moment';
import PerfectScrollbar from 'react-perfect-scrollbar';
import PropTypes from 'prop-types';
import { makeStyles } from '@material-ui/styles';
import {
Card,
CardActions,
CardHeader,
CardContent,
Button,
Divider,
Table,
TableBody,
TableCell,
TableHead,
TableRow,
Tooltip,
TableSortLabel
} from '@material-ui/core';
import ArrowRightIcon from '@material-ui/icons/ArrowRight';
import mockData from './data';
import { StatusBullet } from 'components';
const useStyles = makeStyles(theme => ({
root: {},
content: {
padding: 0
},
inner: {
minWidth: 800
},
statusContainer: {
display: 'flex',
alignItems: 'center'
},
status: {
marginRight: theme.spacing(1)
},
actions: {
justifyContent: 'flex-end'
}
}));
const statusColors = {
delivered: 'success',
pending: 'info',
refunded: 'danger'
};
const LatestOrders = props => {
const { className, ...rest } = props;
const classes = useStyles();
const [orders] = useState(mockData);
return (
<Card
{...rest}
className={clsx(classes.root, className)}
>
<CardHeader
action={
<Button
color="primary"
size="small"
variant="outlined"
>
New entry
</Button>
}
title="Latest Orders"
/>
<Divider />
<CardContent className={classes.content}>
<PerfectScrollbar>
<div className={classes.inner}>
<Table>
<TableHead>
<TableRow>
<TableCell>Order Ref</TableCell>
<TableCell>Customer</TableCell>
<TableCell sortDirection="desc">
<Tooltip
enterDelay={300}
title="Sort"
>
<TableSortLabel
active
direction="desc"
>
Date
</TableSortLabel>
</Tooltip>
</TableCell>
<TableCell>Status</TableCell>
</TableRow>
</TableHead>
<TableBody>
{orders.map(order => (
<TableRow
hover
key={order.id}
>
<TableCell>{order.ref}</TableCell>
<TableCell>{order.customer.name}</TableCell>
<TableCell>
{moment(order.createdAt).format('DD/MM/YYYY')}
</TableCell>
<TableCell>
<div className={classes.statusContainer}>
<StatusBullet
className={classes.status}
color={statusColors[order.status]}
size="sm"
/>
{order.status}
</div>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
</PerfectScrollbar>
</CardContent>
<Divider />
<CardActions className={classes.actions}>
<Button
color="primary"
size="small"
variant="text"
>
View all <ArrowRightIcon />
</Button>
</CardActions>
</Card>
);
};
LatestOrders.propTypes = {
className: PropTypes.string
};
export default LatestOrders;