@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.
@@ -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
- for (const item of menuItems) {
32
- if (currentPath.startsWith(item.path)) {
33
- setSelectedMainMenu(item.text);
34
- return;
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
- setSelectedMainMenu(null);
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;
@@ -31,7 +31,7 @@
31
31
  svg,
32
32
  .MuiSvgIcon-root {
33
33
  width: 24px;
34
- height: 24px;
34
+ height: 25px;
35
35
  display: block;
36
36
  }
37
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cullsin/lnc-menu",
3
- "version": "5.9.0",
3
+ "version": "6.0.0",
4
4
  "description": "Reusable SideMenu component for MedGenome LNC platform using MUI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",