Skip to content

Commit 3c6c5bc

Browse files
committed
refactor sidemenu
1 parent a50ab59 commit 3c6c5bc

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

frontend/src/SideMenu.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,39 @@ 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"
2741
sx={{
2842
width: drawerWidth,
2943
flexShrink: 0,
30-
[`& .MuiDrawer-paper`]: { width: drawerWidth, boxSizing: 'border-box' },
44+
[`& .MuiDrawer-paper`]: { position: 'relative', width: drawerWidth, boxSizing: 'border-box' },
3145
display: { xs:'none', md: 'flex'},
3246
}}
3347
>
34-
<Toolbar />
35-
<Box sx={{ overflow: 'auto' , paddingTop:'5vh'}}>
48+
<Box sx={{ overflow: 'auto'}}>
3649
<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"}>
50+
{menuItems.map((item, index) => (
51+
<ListItem key={item.text} disablePadding style={{ 'borderLeft': context.pageTitle === item.text.toLowerCase() ? 'thick solid #1976d2' : 'none' }}>
52+
<ListItemButton href={item.href}>
4053
<ListItemIcon>
41-
{text === "Home" ? <HomeIcon /> : <CheckIcon />}
54+
{item.icon}
4255
</ListItemIcon>
43-
<ListItemText primary={text === "Dashboard" ? "Validation" : text} />
56+
<ListItemText primary={item.displayText} />
4457
</ListItemButton>
4558
</ListItem>
4659
))}

0 commit comments

Comments
 (0)