Skip to content

Commit

Permalink
company accessible from managers navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
devireddyprasanth22 committed Oct 30, 2024
1 parent 8684591 commit e4bcfe0
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions frontend/src/manager-components/navigation_menu/SideDrawer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ListItem from "@mui/material/ListItem";
import ListItemButton from "@mui/material/ListItemButton";
import ListItemIcon from "@mui/material/ListItemIcon";
import HomeIcon from "@mui/icons-material/Home";
import BusinessIcon from "@mui/icons-material/Business";
import ChatIcon from "@mui/icons-material/Chat";
import InspectionIcon from "@mui/icons-material/Assignment";
import InspectionRunsIcon from "@mui/icons-material/AssignmentTurnedIn";
Expand All @@ -17,27 +18,31 @@ import ContactsIcon from "@mui/icons-material/Contacts";
import KeysIcon from "@mui/icons-material/VpnKey";
import AddPropertyIcon from "@mui/icons-material/Add";
import HelpIcon from "@mui/icons-material/Help";
import { useSelector } from "react-redux"; // Import useSelector
import { useTheme } from "@mui/material";

// Define the drawer width for consistent sizing
const drawerWidth = 200;

// Define the menu items in an array for easier maintenance
const menuItems = [
{ text: "Dashboard", icon: <HomeIcon />, link: "/dashboard" },
{ text: "Messages", icon: <ChatIcon />, link: "/messages" },
{ text: "Inspection", icon: <InspectionIcon />, link: "/inspection" },
{ text: "Inspection Runs", icon: <InspectionRunsIcon />, link: "/InspectionRun" },
{ text: "Applications", icon: <ApplicationsIcon />, link: "/Application" },
{ text: "Properties", icon: <PropertiesIcon />, link: "/property" },
{ text: "Contacts", icon: <ContactsIcon />, link: "/contacts" },
{ text: "Keys", icon: <KeysIcon />, link: "/keys" },
{ text: "Add Property", icon: <AddPropertyIcon />, link: "/add_property" },
//{ text: "Help", icon: <HelpIcon />, link: "/help" }
];
// Sidedrawer to help with navigating around the applcation
// SideDrawer component to help with navigating around the application
export default function SideDrawer() {
const theme = useTheme();
const companyId = useSelector((state) => state.user.currentUser.company_id); // Use useSelector inside the component

// Define the menu items in an array for easier maintenance
const menuItems = [
{ text: "Dashboard", icon: <HomeIcon />, link: "/dashboard" },
{ text: "Company", icon: <BusinessIcon />, link: `/company/${companyId}` }, // Use dynamic companyId
{ text: "Messages", icon: <ChatIcon />, link: "/messages" },
{ text: "Inspection", icon: <InspectionIcon />, link: "/inspection" },
{ text: "Inspection Runs", icon: <InspectionRunsIcon />, link: "/InspectionRun" },
{ text: "Applications", icon: <ApplicationsIcon />, link: "/Application" },
{ text: "Properties", icon: <PropertiesIcon />, link: "/property" },
{ text: "Contacts", icon: <ContactsIcon />, link: "/contacts" },
{ text: "Keys", icon: <KeysIcon />, link: "/keys" },
{ text: "Add Property", icon: <AddPropertyIcon />, link: "/add_property" },
// { text: "Help", icon: <HelpIcon />, link: "/help" }
];

return (
<Drawer
Expand All @@ -47,8 +52,8 @@ export default function SideDrawer() {
flexShrink: 0,
[`& .MuiDrawer-paper`]: {
width: drawerWidth,
boxSizing: "border-box"
}
boxSizing: "border-box",
},
}}
>
<Toolbar />
Expand All @@ -67,11 +72,11 @@ export default function SideDrawer() {
color: "inherit",
padding: 1.7,
paddingLeft: 2,
'&.active': {
"&.active": {
backgroundColor: theme.palette.action.selected,
color: theme.palette.primary.main,
fontWeight: 700
}
fontWeight: 700,
},
}}
>
<ListItemIcon>{item.icon}</ListItemIcon>
Expand Down

0 comments on commit e4bcfe0

Please sign in to comment.