@cullsin/lnc-menu 3.0.9 → 3.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/SideMenu.js +31 -20
- package/package.json +1 -1
package/dist/src/SideMenu.js
CHANGED
|
@@ -12,16 +12,18 @@ import MenuItem from "@mui/material/MenuItem";
|
|
|
12
12
|
import DashboardOutlinedIcon from "@mui/icons-material/DashboardOutlined";
|
|
13
13
|
import RecentActorsOutlinedIcon from "@mui/icons-material/RecentActorsOutlined";
|
|
14
14
|
import ArticleOutlinedIcon from "@mui/icons-material/ArticleOutlined";
|
|
15
|
-
import Tooltip from "@mui/material/Tooltip";
|
|
16
15
|
function SideMenu({ useDrawer, SampleMgmtIcon, navigate }) {
|
|
17
16
|
const [selectedMainMenu, setSelectedMainMenu] = React.useState(null); // Track selected main menu
|
|
17
|
+
const [openMenuIndex, setOpenMenuIndex] = React.useState(null);
|
|
18
18
|
const { isDrawerOpen, toggleDrawer } = useDrawer();
|
|
19
19
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
20
20
|
const handleMenuOpen = (event, index) => {
|
|
21
21
|
setAnchorEl(event.currentTarget);
|
|
22
|
+
setOpenMenuIndex(index); // Keep track of which menu to open
|
|
22
23
|
};
|
|
23
24
|
const handleMenuClose = () => {
|
|
24
25
|
setAnchorEl(null);
|
|
26
|
+
setOpenMenuIndex(null);
|
|
25
27
|
};
|
|
26
28
|
const handleSubMenuItemClick = (path, parentText) => {
|
|
27
29
|
setSelectedMainMenu(parentText); // Set the main menu selected when a submenu item is clicked
|
|
@@ -29,25 +31,34 @@ function SideMenu({ useDrawer, SampleMgmtIcon, navigate }) {
|
|
|
29
31
|
if (isDrawerOpen) {
|
|
30
32
|
toggleDrawer();
|
|
31
33
|
}
|
|
32
|
-
console.log('redirecting', path);
|
|
33
|
-
console.log(navigate);
|
|
34
34
|
navigate(path);
|
|
35
35
|
};
|
|
36
36
|
const menuItems = [
|
|
37
|
-
{
|
|
37
|
+
{
|
|
38
|
+
text: "Home",
|
|
38
39
|
icon: _jsx(DashboardOutlinedIcon, {}),
|
|
39
|
-
subMenu: [
|
|
40
|
-
|
|
41
|
-
], },
|
|
40
|
+
subMenu: [{ text: "Dashboard", path: "/super-site/dashboard" }],
|
|
41
|
+
},
|
|
42
42
|
{
|
|
43
43
|
text: "Patient Management",
|
|
44
44
|
icon: _jsx(RecentActorsOutlinedIcon, {}),
|
|
45
45
|
subMenu: [
|
|
46
|
-
{ text: "Patient", path: "patient/patient-listing" },
|
|
47
|
-
{ text: "Family", path: "patient/family-listing" },
|
|
46
|
+
{ text: "Patient", path: "/patient/patient-listing" },
|
|
47
|
+
{ text: "Family", path: "/patient/family-listing" },
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
text: "Sample Management",
|
|
52
|
+
icon: _jsx(SampleMgmtIcon, {}),
|
|
53
|
+
subMenu: [
|
|
54
|
+
{ text: "Dashboard", path: "/sample/sample-dashboard" },
|
|
55
|
+
{ text: "Sample Listing", path: "/sample/sample-listing" },
|
|
56
|
+
{
|
|
57
|
+
text: "Single Sample Analysis",
|
|
58
|
+
path: "/sample/single-sample-analysis",
|
|
59
|
+
},
|
|
48
60
|
],
|
|
49
61
|
},
|
|
50
|
-
{ text: "Sample Management", icon: _jsx(SampleMgmtIcon, {}) },
|
|
51
62
|
{ text: "Reports", icon: _jsx(ArticleOutlinedIcon, {}) },
|
|
52
63
|
];
|
|
53
64
|
return (_jsxs(Box, { sx: { flexGrow: 1 }, children: [_jsx(AppBar, { sx: { position: "fixed", top: 0 } }), _jsx(Drawer, { open: isDrawerOpen, variant: "permanent", className: "parent-container", sx: {
|
|
@@ -60,16 +71,16 @@ function SideMenu({ useDrawer, SampleMgmtIcon, navigate }) {
|
|
|
60
71
|
bottom: "0",
|
|
61
72
|
borderRight: "1px solid #B1BECB",
|
|
62
73
|
},
|
|
63
|
-
}, children: _jsx(List, { children: menuItems.map((item, index) => (_jsxs(React.Fragment, { children: [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
}, children: _jsx(List, { children: menuItems.map((item, index) => (_jsxs(React.Fragment, { children: [_jsxs(ListItem, { button: true, selected: selectedMainMenu === item.text, className: selectedMainMenu === item.text ? "selected" : "", onClick: (event) => {
|
|
75
|
+
if (item.subMenu) {
|
|
76
|
+
handleMenuOpen(event, index);
|
|
77
|
+
setSelectedMainMenu(item.text); // Set selected when main menu is clicked
|
|
78
|
+
}
|
|
79
|
+
else if (item.onClick) {
|
|
80
|
+
item.onClick();
|
|
81
|
+
setSelectedMainMenu(item.text); // Set selected when a menu is clicked
|
|
82
|
+
}
|
|
83
|
+
}, children: [_jsx(ListItemIcon, { children: item.icon }), isDrawerOpen && _jsx(ListItemText, { primary: item.text })] }), item.subMenu && anchorEl && openMenuIndex === index && (_jsxs(Menu, { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleMenuClose, anchorOrigin: {
|
|
73
84
|
vertical: "top",
|
|
74
85
|
horizontal: "left",
|
|
75
86
|
}, transformOrigin: {
|