fix: resolved key prop error
This commit is contained in:
1 parent
01098b92f9
commit
384f40a4b4
2 files changed
+36
-59
No files matched your search
@@ -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);
|
|
||||||
}
|
|
||||||
@@ -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,35 +142,45 @@ 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) => {
|
||||||
<ListItemButton
|
if (
|
||||||
className={
|
child.name === "Team" &&
|
||||||
location.pathname.includes(child.path)
|
authState.user?.role &&
|
||||||
? "selected-path"
|
!authState.user.role.includes("admin")
|
||||||
: ""
|
) {
|
||||||
}
|
return null;
|
||||||
key={child.path}
|
}
|
||||||
onClick={() => navigate(`/${child.path}`)}
|
|
||||||
sx={{
|
return (
|
||||||
gap: theme.gap.medium,
|
<ListItemButton
|
||||||
borderRadius: `${theme.shape.borderRadius}px`,
|
className={
|
||||||
}}
|
location.pathname.includes(child.path)
|
||||||
>
|
? "selected-path"
|
||||||
<ListItemIcon sx={{ minWidth: 0 }}>
|
: ""
|
||||||
{child.icon}
|
}
|
||||||
</ListItemIcon>
|
key={child.path}
|
||||||
<ListItemText>{child.name}</ListItemText>
|
onClick={() => navigate(`/${child.path}`)}
|
||||||
</ListItemButton>
|
sx={{
|
||||||
))}
|
gap: theme.gap.medium,
|
||||||
|
borderRadius: `${theme.shape.borderRadius}px`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ListItemIcon sx={{ minWidth: 0 }}>
|
||||||
|
{child.icon}
|
||||||
|
</ListItemIcon>
|
||||||
|
<ListItemText>{child.name}</ListItemText>
|
||||||
|
</ListItemButton>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</List>
|
</List>
|
||||||
</Collapse>
|
</Collapse>
|
||||||
</>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
</List>
|
</List>
|
||||||
|
|||||||
Reference in new issue
Block a user