|
1 | 1 | import React, { useState } from 'react';
|
2 |
| -import { Menu, Button } from 'antd'; |
| 2 | +import { Menu } from 'antd'; |
3 | 3 | import { Link } from 'react-router-dom';
|
4 |
| -import { |
5 |
| - CarOutlined, |
6 |
| - UsergroupAddOutlined , |
7 |
| - MenuFoldOutlined, |
8 |
| - MenuUnfoldOutlined, |
9 |
| - PieChartOutlined, |
10 |
| - HomeOutlined, |
11 |
| - InfoCircleOutlined, |
12 |
| - PhoneOutlined, |
13 |
| - UserOutlined, |
14 |
| - AreaChartOutlined, |
15 |
| - HistoryOutlined, |
16 |
| - BarChartOutlined, |
17 |
| - DollarOutlined |
18 |
| - } from '@ant-design/icons'; |
| 4 | +import { |
| 5 | + CarOutlined, |
| 6 | + UsergroupAddOutlined, |
| 7 | + PieChartOutlined, |
| 8 | + HomeOutlined, |
| 9 | + InfoCircleOutlined, |
| 10 | + PhoneOutlined, |
| 11 | + UserOutlined, |
| 12 | + AreaChartOutlined, |
| 13 | + HistoryOutlined, |
| 14 | + BarChartOutlined, |
| 15 | + DollarOutlined, |
| 16 | +} from '@ant-design/icons'; |
19 | 17 |
|
20 | 18 | function getItem(label, key, icon, children, type, link) {
|
21 |
| - return { |
22 |
| - key, |
23 |
| - icon, |
24 |
| - children, |
25 |
| - label, |
26 |
| - type, |
27 |
| - link, |
28 |
| - }; |
| 19 | + return { |
| 20 | + key, |
| 21 | + icon, |
| 22 | + children, |
| 23 | + label, |
| 24 | + type, |
| 25 | + link, |
| 26 | + }; |
29 | 27 | }
|
30 | 28 |
|
31 | 29 | const items = [
|
32 |
| - getItem('Inicio', '1', <HomeOutlined />, null, null, '/dashboard'), |
33 |
| - getItem('Parqueo', '2', <PieChartOutlined />, null, null, '/park'), |
34 |
| - getItem('Historial de Parqueo', '3', <HistoryOutlined />, null, null, '/parkhistory'), |
35 |
| - getItem('Estadísticas de Parqueo', '4', <BarChartOutlined />, null, null, '/parkingstatistics'), |
36 |
| - getItem('Usuarios', '5', <UserOutlined />, null, null, '/users'), |
37 |
| - getItem('Clientes', 'sub2', <UsergroupAddOutlined />, [ |
38 |
| - getItem('Ver Clientes', '6', null, null, null, '/customers'), |
39 |
| - getItem('Clientes frecuentes', '7', null, null, null, '/usual_customers'), |
40 |
| - ]), |
41 |
| - getItem('Vehículos', 'sub1', <CarOutlined />, [ |
42 |
| - getItem('Ver Vehículos', '8', null, null, null, '/vehicles'), |
43 |
| - getItem('Historial de Vehículos', '9', null, null, null, '/vehicleshistory'), |
44 |
| - ]), |
45 |
| - getItem('Ingresos', 'sub3', <AreaChartOutlined />, [ |
46 |
| - getItem('Ingresos diarios', '10', null, null, null, '/dailyincome'), |
47 |
| - getItem('Historial de Ingresos', '11', null, null, null, '/incomehistory'), |
48 |
| - getItem('Estadísticas de Ingresos', '12', null, null, null, '/incomestatistics'), |
49 |
| - ]), |
50 |
| - getItem('Precio Estacionamiento', '13', <DollarOutlined />, null, null, '/module_parking_price'), |
51 |
| - getItem('Información', '14', <InfoCircleOutlined />, null, null, '/module_about'), |
52 |
| - getItem('Contacto', '15', <PhoneOutlined />, null, null, '/module_contact') |
| 30 | + getItem('Inicio', '1', <HomeOutlined />, null, null, '/dashboard'), |
| 31 | + getItem('Parqueo', '2', <PieChartOutlined />, null, null, '/park'), |
| 32 | + getItem( |
| 33 | + 'Historial de Parqueo', |
| 34 | + '3', |
| 35 | + <HistoryOutlined />, |
| 36 | + null, |
| 37 | + null, |
| 38 | + '/parkhistory' |
| 39 | + ), |
| 40 | + getItem( |
| 41 | + 'Estadísticas de Parqueo', |
| 42 | + '4', |
| 43 | + <BarChartOutlined />, |
| 44 | + null, |
| 45 | + null, |
| 46 | + '/parkingstatistics' |
| 47 | + ), |
| 48 | + getItem('Usuarios', '5', <UserOutlined />, null, null, '/users'), |
| 49 | + getItem('Clientes', 'sub2', <UsergroupAddOutlined />, [ |
| 50 | + getItem('Ver Clientes', '6', null, null, null, '/customers'), |
| 51 | + getItem('Clientes frecuentes', '7', null, null, null, '/usual_customers'), |
| 52 | + ]), |
| 53 | + getItem('Vehículos', 'sub1', <CarOutlined />, [ |
| 54 | + getItem('Ver Vehículos', '8', null, null, null, '/vehicles'), |
| 55 | + getItem( |
| 56 | + 'Historial de Vehículos', |
| 57 | + '9', |
| 58 | + null, |
| 59 | + null, |
| 60 | + null, |
| 61 | + '/vehicleshistory' |
| 62 | + ), |
| 63 | + ]), |
| 64 | + getItem('Ingresos', 'sub3', <AreaChartOutlined />, [ |
| 65 | + getItem('Ingresos diarios', '10', null, null, null, '/dailyincome'), |
| 66 | + getItem('Historial de Ingresos', '11', null, null, null, '/incomehistory'), |
| 67 | + getItem( |
| 68 | + 'Estadísticas de Ingresos', |
| 69 | + '12', |
| 70 | + null, |
| 71 | + null, |
| 72 | + null, |
| 73 | + '/incomestatistics' |
| 74 | + ), |
| 75 | + ]), |
| 76 | + getItem( |
| 77 | + 'Precio Estacionamiento', |
| 78 | + '13', |
| 79 | + <DollarOutlined />, |
| 80 | + null, |
| 81 | + null, |
| 82 | + '/module_parking_price' |
| 83 | + ), |
| 84 | + getItem( |
| 85 | + 'Información', |
| 86 | + '14', |
| 87 | + <InfoCircleOutlined />, |
| 88 | + null, |
| 89 | + null, |
| 90 | + '/module_about' |
| 91 | + ), |
| 92 | + getItem('Contacto', '15', <PhoneOutlined />, null, null, '/module_contact'), |
53 | 93 | ];
|
54 | 94 |
|
55 | 95 | const LeftMenu = () => {
|
56 |
| - const [collapsed, setCollapsed] = useState(false); |
57 |
| - const toggleCollapsed = () => { |
58 |
| - setCollapsed(!collapsed); |
59 |
| - }; |
| 96 | + const [collapsed, setCollapsed] = useState(false); |
| 97 | + const toggleCollapsed = () => { |
| 98 | + setCollapsed(!collapsed); |
| 99 | + }; |
60 | 100 |
|
61 |
| - const buttonWidth = collapsed ? `${collapsed ? 20 : 200}px` : 'auto' ; |
62 |
| - |
63 |
| - return ( |
64 |
| - <div className='left-menu-div'> |
65 |
| - {/* |
66 |
| - <Button |
67 |
| - type="primary" |
68 |
| - //onClick={toggleCollapsed} |
69 |
| - style={{ |
70 |
| - borderRadius: 0, |
71 |
| - width: buttonWidth, |
72 |
| - height: '-5px', |
73 |
| - }} |
74 |
| - > |
75 |
| - {collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />} |
76 |
| - </Button> |
77 |
| - */} |
78 |
| - <Menu |
79 |
| - defaultOpenKeys={items.map(item => item.key)} |
80 |
| - mode="inline" |
81 |
| - theme="dark" |
82 |
| - inlineCollapsed={collapsed} |
83 |
| - style={{}} |
84 |
| - className='left-menu' |
85 |
| - > |
86 |
| - {items.map(item => ( |
87 |
| - item.children ? ( |
88 |
| - <Menu.SubMenu key={item.key} icon={item.icon} title={item.label}> |
89 |
| - {item.children.map(subItem => ( |
90 |
| - <Menu.Item key={subItem.key} icon={subItem.icon}> |
91 |
| - <Link to={subItem.link}>{subItem.label}</Link> |
92 |
| - </Menu.Item> |
93 |
| - ))} |
94 |
| - </Menu.SubMenu> |
95 |
| - ) : ( |
96 |
| - <Menu.Item key={item.key} icon={item.icon}> |
97 |
| - <Link to={item.link}>{item.label}</Link> |
98 |
| - </Menu.Item> |
99 |
| - ) |
100 |
| - ))} |
101 |
| - </Menu> |
102 |
| - </div> |
103 |
| - ) |
104 |
| -} |
| 101 | + return ( |
| 102 | + <div className='left-menu-div'> |
| 103 | + <Menu |
| 104 | + defaultOpenKeys={items.map((item) => item.key)} |
| 105 | + mode='inline' |
| 106 | + theme='dark' |
| 107 | + inlineCollapsed={collapsed} |
| 108 | + style={{}} |
| 109 | + className='left-menu' |
| 110 | + > |
| 111 | + {items.map((item) => |
| 112 | + item.children ? ( |
| 113 | + <Menu.SubMenu key={item.key} icon={item.icon} title={item.label}> |
| 114 | + {item.children.map((subItem) => ( |
| 115 | + <Menu.Item key={subItem.key} icon={subItem.icon}> |
| 116 | + <Link to={subItem.link}>{subItem.label}</Link> |
| 117 | + </Menu.Item> |
| 118 | + ))} |
| 119 | + </Menu.SubMenu> |
| 120 | + ) : ( |
| 121 | + <Menu.Item key={item.key} icon={item.icon}> |
| 122 | + <Link to={item.link}>{item.label}</Link> |
| 123 | + </Menu.Item> |
| 124 | + ) |
| 125 | + )} |
| 126 | + </Menu> |
| 127 | + </div> |
| 128 | + ); |
| 129 | +}; |
105 | 130 |
|
106 | 131 | export default LeftMenu;
|
0 commit comments