fix: resolved key prop error

This commit is contained in:
Daniel Cojocea committed 2024-08-16 12:40:15 -04:00
1 parent 01098b92f9
commit 384f40a4b4
2 files changed
+18 -41

No files matched your search

+2 -28
View File
@@ -1,6 +1,5 @@
aside .selected-path, aside .selected-path,
aside .MuiListItemButton-root:hover, aside .MuiListItemButton-root:hover {
aside .MuiStack-root:hover {
background-color: var(--env-var-color-13); background-color: var(--env-var-color-13);
} }
aside .MuiList-root svg { aside .MuiList-root svg {
@@ -28,7 +27,7 @@ aside .MuiListSubheader-root {
color: var(--env-var-color-5); color: var(--env-var-color-5);
} }
aside .MuiListItemButton-root:not(.selected-path) > * { aside .MuiListItemButton-root:not(.selected-path) > * {
opacity: 0.8; opacity: 0.9;
} }
aside .selected-path > * { aside .selected-path > * {
opacity: 1; opacity: 1;
@@ -39,28 +38,3 @@ aside .selected-path span.MuiTypography-root {
aside .MuiStack-root:last-child { aside .MuiStack-root:last-child {
margin-top: auto; margin-top: auto;
} }
.sidebar-menu {
margin-top: -20px;
}
.sidebar-menu .MuiPaper-root {
box-shadow: var(--env-var-shadow-1);
border: solid 1px var(--env-var-color-6);
border-radius: var(--env-var-radius-1);
gap: 1px;
}
.sidebar-menu .MuiList-root {
min-width: 100px;
width: 150px;
}
.sidebar-menu li.MuiButtonBase-root {
min-height: fit-content;
}
.sidebar-menu .MuiList-root svg {
width: 16px;
height: 16px;
}
.sidebar-menu span {
font-size: var(--env-var-font-size-medium);
color: var(--env-var-color-2);
}
+16 -13
View File
@@ -1,4 +1,4 @@
import { useState } from "react"; import React, { useState } from "react";
import { import {
Box, Box,
Collapse, Collapse,
@@ -81,12 +81,6 @@ function Sidebar() {
const authState = useSelector((state) => state.auth); const authState = useSelector((state) => state.auth);
const [open, setOpen] = useState({ Dashboard: false, Account: false }); const [open, setOpen] = useState({ Dashboard: false, Account: false });
// Initialize settings and update based on user role
let settings = ["Profile", "Password", "Team", "Logout"];
if (authState.user?.role && !authState.user.role.includes("admin")) {
settings = ["Profile", "Password", "Logout"];
}
/** /**
* Handles logging out the user * Handles logging out the user
* *
@@ -131,9 +125,8 @@ function Sidebar() {
<ListItemText>{item.name}</ListItemText> <ListItemText>{item.name}</ListItemText>
</ListItemButton> </ListItemButton>
) : ( ) : (
<> <React.Fragment key={item.name}>
<ListItemButton <ListItemButton
key={item.name}
onClick={() => onClick={() =>
setOpen((prev) => ({ setOpen((prev) => ({
...prev, ...prev,
@@ -149,13 +142,22 @@ function Sidebar() {
<ListItemText>{item.name}</ListItemText> <ListItemText>{item.name}</ListItemText>
{open[`${item.name}`] ? <ArrowUp /> : <ArrowDown />} {open[`${item.name}`] ? <ArrowUp /> : <ArrowDown />}
</ListItemButton> </ListItemButton>
<Collapse in={open[`${item.name}`]} timeout="auto" unmountOnExit> <Collapse in={open[`${item.name}`]} timeout="auto">
<List <List
component="div" component="div"
disablePadding disablePadding
sx={{ pl: theme.gap.large }} sx={{ pl: theme.gap.large }}
> >
{item.nested.map((child) => ( {item.nested.map((child) => {
if (
child.name === "Team" &&
authState.user?.role &&
!authState.user.role.includes("admin")
) {
return null;
}
return (
<ListItemButton <ListItemButton
className={ className={
location.pathname.includes(child.path) location.pathname.includes(child.path)
@@ -174,10 +176,11 @@ function Sidebar() {
</ListItemIcon> </ListItemIcon>
<ListItemText>{child.name}</ListItemText> <ListItemText>{child.name}</ListItemText>
</ListItemButton> </ListItemButton>
))} );
})}
</List> </List>
</Collapse> </Collapse>
</> </React.Fragment>
) )
)} )}
</List> </List>