-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenuList.js
123 lines (118 loc) · 2.96 KB
/
MenuList.js
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
import {
Table,
Thead,
Tbody,
Tr,
Th,
TableContainer,
Switch,
Input,
Button,
Box,
useColorModeValue,
Center,
Flex,
Text,
VStack,
Icon,
Td,
} from "@chakra-ui/react";
import { FaRupeeSign } from "react-icons/fa";
import { EditIcon, AddIcon } from "@chakra-ui/icons";
function MenuList({
itemData,
toggleStatus,
handleChange,
handleOnClickEditItem,
handleOnAddClick,
}) {
const tableHeader = [
"Item",
"Price",
"Category Name",
"Description",
"Actions",
];
return (
<>
<Box
p={4}
mx="20"
bg={useColorModeValue("white", "gray.800")}
rounded={"md"}
>
<Flex>
<Center flex="1">
<Input
variant="outline"
width={500}
rounded={"full"}
border={0}
bg={useColorModeValue("gray.200", "gray.800")}
type="text"
placeholder="Search by Item Name or Category..."
onChange={handleChange}
/>
</Center>
<Button
onClick={handleOnAddClick}
size="md"
variant={"link"}
rounded={"full"}
>
<VStack>
<AddIcon color="blue.500" />
<Text color="blue.500">Add Item</Text>
</VStack>
</Button>
</Flex>
<TableContainer overflow-x="auto" overflow-y="hidden">
<Table variant="striped" colorScheme="gray" size="md">
<Thead fontweights="900">
<Tr>
{tableHeader.map((header, index) => (
<Th
textAlign={
index === tableHeader.length - 1 ? "right" : "left"
}
key={header}
>
{header}{" "}
</Th>
))}
</Tr>
</Thead>
<Tbody>
{itemData.map((item) => (
<Tr key={item.id}>
<Td>{item.itemname}</Td>
<Td>
<Icon as={FaRupeeSign} />
{Number(item.price).toFixed(2)}
</Td>
<Td>{item.categoryname}</Td>
<Td>{item.description}</Td>
<Td textAlign="right" maxW="10%">
<Switch
isChecked={item.active}
colorScheme="blue"
size="lg"
onChange={() => toggleStatus(item.id)}
/>
<Button
onClick={() => handleOnClickEditItem(item)}
variant="link"
>
<EditIcon color="blue.500" />
</Button>
</Td>
</Tr>
))}
</Tbody>
</Table>
</TableContainer>
</Box>
</>
);
}
export default MenuList;