@cullsin/lnc-menu 5.9.0 → 6.0.0
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 +16 -7
- package/dist/src/src/sidemenu.scss +1 -1
- package/package.json +1 -1
package/dist/src/SideMenu.js
CHANGED
|
@@ -25,17 +25,26 @@ function SideMenu({ useDrawer, SampleMgmtIcon, location, language = 'en' }) {
|
|
|
25
25
|
path: `/sample/${language}/sample-listing`,
|
|
26
26
|
},
|
|
27
27
|
], [SampleMgmtIcon, t, language]);
|
|
28
|
-
// Sync selection with current path
|
|
28
|
+
// Sync selection with current path using regex to extract first path segment
|
|
29
29
|
React.useEffect(() => {
|
|
30
30
|
const currentPath = location.pathname;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const pathMatch = currentPath.match(/^\/([^/]+)/);
|
|
32
|
+
if (pathMatch) {
|
|
33
|
+
const firstSegment = pathMatch[1].toLowerCase();
|
|
34
|
+
if (firstSegment === 'sample') {
|
|
35
|
+
setSelectedMainMenu(t.menu.sampleManagement);
|
|
35
36
|
}
|
|
37
|
+
else if (firstSegment === 'patient') {
|
|
38
|
+
setSelectedMainMenu(t.menu.patientManagement);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
setSelectedMainMenu(null);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
setSelectedMainMenu(null);
|
|
36
46
|
}
|
|
37
|
-
|
|
38
|
-
}, [location.pathname, menuItems]);
|
|
47
|
+
}, [location.pathname, t.menu.sampleManagement, t.menu.patientManagement]);
|
|
39
48
|
const handleMenuClick = (item) => {
|
|
40
49
|
setSelectedMainMenu(item.text);
|
|
41
50
|
window.location.href = item.path;
|