-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItemsList.tsx
More file actions
65 lines (63 loc) · 2.14 KB
/
ItemsList.tsx
File metadata and controls
65 lines (63 loc) · 2.14 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
import { RootState } from '@/store'
import numberFormat from '@/tests/numberFormat'
import { TableContainer, Paper, Table, TableHead, TableRow, TableCell, TableBody, IconButton, Fab } from '@mui/material'
import EditIcon from '@mui/icons-material/Edit'
import DeleteIcon from '@mui/icons-material/Delete'
import AddIcon from '@mui/icons-material/Add'
import { useSelector } from 'react-redux'
import { useNavigate } from 'react-router'
export function ItemsList() {
const items = useSelector((state: RootState) => state.rules.items)
const navigate = useNavigate()
return (
<>
<TableContainer component={Paper}>
<Table aria-label="simple table">
<TableHead>
<TableRow>
<TableCell>Name</TableCell>
<TableCell align="right">Price</TableCell>
<TableCell align="right">Lines per seconds</TableCell>
<TableCell align="right">Action</TableCell>
</TableRow>
</TableHead>
<TableBody>
{items.map(item => (
<TableRow key={item.id}>
<TableCell component="th" scope="row">{item.name}</TableCell>
<TableCell align="right">{numberFormat(item.price)}</TableCell>
<TableCell align="right">{numberFormat(item.linesPerMillisecond * 10)}</TableCell>
<TableCell align="right">
<IconButton
onClick={() => navigate(`/rules/edit/${item.id}`)}
aria-label="edit"
>
<EditIcon />
</IconButton>
<IconButton
color="error"
aria-label="delete"
>
<DeleteIcon />
</IconButton>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
<Fab
onClick={() => navigate('/rules/add')}
color="primary"
aria-label="add"
sx={{
position: 'fixed',
bottom: 16,
right: 16,
}}
>
<AddIcon />
</Fab>
</>
)
}