Skip to content

Commit 8dcca35

Browse files
committed
refactor sidemenu
1 parent a50ab59 commit 8dcca35

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

frontend/src/SideMenu.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ const drawerWidth = 240;
2121
export default function SideMenu() {
2222

2323
const context = useContext(PageContext);
24+
25+
const menuItems = [{
26+
text: "Home",
27+
href: context.sandboxId ? `/sandbox/${context.sandboxId}` : "/",
28+
icon: <HomeIcon />,
29+
displayText: "Home",
30+
},
31+
{
32+
text: "Dashboard",
33+
href: context.sandboxId ? `/sandbox/dashboard/${context.sandboxId}` : "/dashboard",
34+
icon: <CheckIcon />,
35+
displayText: "Validation",
36+
},];
37+
2438
return (
2539
<Drawer
2640
variant="permanent"
@@ -34,13 +48,13 @@ export default function SideMenu() {
3448
<Toolbar />
3549
<Box sx={{ overflow: 'auto' , paddingTop:'5vh'}}>
3650
<List>
37-
{['Home', 'Dashboard'].map((text, index) => (
38-
<ListItem key={text} disablePadding style={{ 'borderLeft': context.pageTitle === text.toLowerCase() ? 'thick solid #1976d2' : 'none' }}>
39-
<ListItemButton href={text === "Home" ? context.sandboxId ? `/sandbox/${context.sandboxId}` : "/" : context.sandboxId ? `/sandbox/dashboard/${context.sandboxId}` : "/dashboard"}>
51+
{menuItems.map((item, index) => (
52+
<ListItem key={item.text} disablePadding style={{ 'borderLeft': context.pageTitle === item.text.toLowerCase() ? 'thick solid #1976d2' : 'none' }}>
53+
<ListItemButton href={item.href}>
4054
<ListItemIcon>
41-
{text === "Home" ? <HomeIcon /> : <CheckIcon />}
55+
{item.icon}
4256
</ListItemIcon>
43-
<ListItemText primary={text === "Dashboard" ? "Validation" : text} />
57+
<ListItemText primary={item.displayText} />
4458
</ListItemButton>
4559
</ListItem>
4660
))}

0 commit comments

Comments
 (0)