|
@ -21,6 +21,7 @@ import styled from "@emotion/styled"; |
|
|
import { BUILDING, GEAR } from "@/utilities/svgConstant"; |
|
|
import { BUILDING, GEAR } from "@/utilities/svgConstant"; |
|
|
import LogoutIcon from "@mui/icons-material/Logout"; |
|
|
import LogoutIcon from "@mui/icons-material/Logout"; |
|
|
import { useRouter } from "next/navigation"; |
|
|
import { useRouter } from "next/navigation"; |
|
|
|
|
|
import { useSelector } from "react-redux"; |
|
|
|
|
|
|
|
|
const drawerWidth = 260; |
|
|
const drawerWidth = 260; |
|
|
|
|
|
|
|
@ -74,7 +75,8 @@ export default function DashboardWrapper(props: Props) { |
|
|
const { children: Children } = props; |
|
|
const { children: Children } = props; |
|
|
const [mobileOpen, setMobileOpen] = useState(false); |
|
|
const [mobileOpen, setMobileOpen] = useState(false); |
|
|
const [isClosing, setIsClosing] = useState(false); |
|
|
const [isClosing, setIsClosing] = useState(false); |
|
|
const router = useRouter() |
|
|
|
|
|
|
|
|
const userData = useSelector((state: any) => state?.auth); |
|
|
|
|
|
const router = useRouter(); |
|
|
const handleDrawerClose = () => { |
|
|
const handleDrawerClose = () => { |
|
|
setIsClosing(true); |
|
|
setIsClosing(true); |
|
|
setMobileOpen(false); |
|
|
setMobileOpen(false); |
|
@ -91,6 +93,10 @@ export default function DashboardWrapper(props: Props) { |
|
|
}; |
|
|
}; |
|
|
const [activeIndex, setActiveIndex] = useState<number | null>(null); |
|
|
const [activeIndex, setActiveIndex] = useState<number | null>(null); |
|
|
|
|
|
|
|
|
|
|
|
React.useEffect(() => { |
|
|
|
|
|
console.log("User Data", userData); |
|
|
|
|
|
}, [userData]); |
|
|
|
|
|
|
|
|
const drawer = ( |
|
|
const drawer = ( |
|
|
<> |
|
|
<> |
|
|
<Toolbar sx={{ minHeight: "72px !important" }}> |
|
|
<Toolbar sx={{ minHeight: "72px !important" }}> |
|
@ -106,7 +112,7 @@ export default function DashboardWrapper(props: Props) { |
|
|
<ListItem |
|
|
<ListItem |
|
|
key={text} |
|
|
key={text} |
|
|
disablePadding |
|
|
disablePadding |
|
|
selected={activeIndex === index} // Add this line to make the item "active"
|
|
|
|
|
|
|
|
|
selected={true} // Add this line to make the item "active"
|
|
|
onClick={() => setActiveIndex(index)} // Add this line to handle click events
|
|
|
onClick={() => setActiveIndex(index)} // Add this line to handle click events
|
|
|
> |
|
|
> |
|
|
<ListItemButton> |
|
|
<ListItemButton> |
|
@ -125,10 +131,10 @@ export default function DashboardWrapper(props: Props) { |
|
|
window !== undefined ? () => window().document.body : undefined; |
|
|
window !== undefined ? () => window().document.body : undefined; |
|
|
|
|
|
|
|
|
const logoutHandler = () => { |
|
|
const logoutHandler = () => { |
|
|
localStorage.removeItem('token'); |
|
|
|
|
|
localStorage.removeItem('refreshToken'); |
|
|
|
|
|
router.push('/log-in'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
localStorage.removeItem("token"); |
|
|
|
|
|
localStorage.removeItem("refreshToken"); |
|
|
|
|
|
router.push("/log-in"); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<Box |
|
|
<Box |
|
@ -169,18 +175,34 @@ export default function DashboardWrapper(props: Props) { |
|
|
borderRadius: "30px", |
|
|
borderRadius: "30px", |
|
|
}} |
|
|
}} |
|
|
> |
|
|
> |
|
|
<Avatar |
|
|
|
|
|
sx={{ |
|
|
|
|
|
width: 34, |
|
|
|
|
|
height: 34, |
|
|
|
|
|
cursor: "pointer", |
|
|
|
|
|
background: "var(--primary_light)", |
|
|
|
|
|
color: "var(--primary_Active_text)", |
|
|
|
|
|
fontSize: "0.8rem", |
|
|
|
|
|
}} |
|
|
|
|
|
alt="Remy Sharp" |
|
|
|
|
|
src="/static/images/avatar/1.jpg" |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
{userData?.image && userData?.image?.length > 0 ? ( |
|
|
|
|
|
<Avatar |
|
|
|
|
|
sx={{ |
|
|
|
|
|
width: 34, |
|
|
|
|
|
height: 34, |
|
|
|
|
|
cursor: "pointer", |
|
|
|
|
|
background: "var(--primary_light)", |
|
|
|
|
|
color: "var(--primary_Active_text)", |
|
|
|
|
|
fontSize: "0.8rem", |
|
|
|
|
|
}} |
|
|
|
|
|
alt="Remy Sharp" |
|
|
|
|
|
src={userData?.image} |
|
|
|
|
|
/> |
|
|
|
|
|
) : ( |
|
|
|
|
|
<Avatar |
|
|
|
|
|
sx={{ |
|
|
|
|
|
width: 34, |
|
|
|
|
|
height: 34, |
|
|
|
|
|
cursor: "pointer", |
|
|
|
|
|
background: "var(--primary_light)", |
|
|
|
|
|
color: "var(--primary_Active_text)", |
|
|
|
|
|
fontSize: "0.8rem", |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
|
|
|
{userData?.firstName?.charAt(0)} |
|
|
|
|
|
</Avatar> |
|
|
|
|
|
)} |
|
|
|
|
|
|
|
|
<IconButton aria-label="log out" size="medium" color="error"> |
|
|
<IconButton aria-label="log out" size="medium" color="error"> |
|
|
<LogoutIcon fontSize="small" onClick={logoutHandler} /> |
|
|
<LogoutIcon fontSize="small" onClick={logoutHandler} /> |
|
|
</IconButton> |
|
|
</IconButton> |
|
|