@@ -9,6 +9,9 @@ import styles from '../../stylesheets/layouts/sidebar/sidebar.module.css';
99import { Typography , Box , IconButton , Divider } from '@mui/material' ;
1010import HomeIcon from '@mui/icons-material/Home' ;
1111import AlignHorizontalLeftIcon from '@mui/icons-material/AlignHorizontalLeft' ;
12+ import RateReviewIcon from '@mui/icons-material/RateReview' ;
13+ import DashboardIcon from '@mui/icons-material/Dashboard' ;
14+ import VolunteerActivismIcon from '@mui/icons-material/VolunteerActivism' ;
1215import FolderIcon from '@mui/icons-material/Folder' ;
1316import SyncAltIcon from '@mui/icons-material/SyncAlt' ;
1417import GroupIcon from '@mui/icons-material/Group' ;
@@ -21,7 +24,10 @@ import NavUserMenu from '../PageTitle/NavUserMenu';
2124import DrawerHeader from '../../components/DrawerHeader' ;
2225import { Cached , ChevronLeft , ChevronRight } from '@mui/icons-material' ;
2326import { useHomePageContext } from '../../app/HomePageContext' ;
24- import { isGuest } from 'shared' ;
27+ import { isGuest , TeamType } from 'shared' ;
28+ import * as MuiIcons from '@mui/icons-material' ;
29+ import { useAllTeamTypes } from '../../hooks/team-types.hooks' ;
30+ import ErrorPage from '../../pages/ErrorPage' ;
2531import BarChartIcon from '@mui/icons-material/BarChart' ;
2632import { useCurrentUser } from '../../hooks/users.hooks' ;
2733import QueryStatsIcon from '@mui/icons-material/QueryStats' ;
@@ -40,29 +46,69 @@ const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: Sid
4046 const [ openSubmenu , setOpenSubmenu ] = useState < string | null > ( null ) ;
4147 const { onPNMHomePage, onOnboardingHomePage } = useHomePageContext ( ) ;
4248 const user = useCurrentUser ( ) ;
49+ const { onGuestHomePage } = useHomePageContext ( ) ;
50+ const { isError : teamsError , error : teamsErrorMsg , data : teams } = useAllTeamTypes ( ) ;
4351
52+ const allTeams : LinkItem [ ] = ( teams ?? [ ] ) . map ( ( team : TeamType ) => {
53+ const IconComponent = MuiIcons [ ( team . iconName in MuiIcons ? team . iconName : 'Circle' ) as keyof typeof MuiIcons ] ;
54+ return {
55+ name : team . name ,
56+ icon : < IconComponent /> ,
57+ route : routes . TEAMS + '/' + team . teamTypeId
58+ } ;
59+ } ) ;
60+
61+ if ( teamsError ) return < ErrorPage error = { teamsErrorMsg } /> ;
4462 const memberLinkItems : LinkItem [ ] = [
4563 {
4664 name : 'Home' ,
4765 icon : < HomeIcon /> ,
48- route : routes . HOME
66+ route : onGuestHomePage ? routes . HOME_GUEST : routes . HOME
4967 } ,
50- {
68+ ! onGuestHomePage && {
5169 name : 'Gantt' ,
5270 icon : < AlignHorizontalLeftIcon /> ,
5371 route : routes . GANTT
5472 } ,
55- {
56- name : 'Projects' ,
57- icon : < FolderIcon /> ,
58- route : routes . PROJECTS
59- } ,
60- {
73+ ! onGuestHomePage
74+ ? {
75+ name : 'Projects' ,
76+ icon : < FolderIcon /> ,
77+ route : routes . PROJECTS
78+ }
79+ : {
80+ name : 'Project Management' ,
81+ icon : < DashboardIcon /> ,
82+ route : routes . PROJECTS ,
83+ subItems : [
84+ {
85+ name : 'Gantt' ,
86+ icon : < AlignHorizontalLeftIcon /> ,
87+ route : routes . GANTT
88+ } ,
89+ {
90+ name : 'Projects' ,
91+ icon : < FolderIcon /> ,
92+ route : routes . PROJECTS
93+ } ,
94+ {
95+ name : 'Change Requests' ,
96+ icon : < SyncAltIcon /> ,
97+ route : routes . CHANGE_REQUESTS
98+ } ,
99+ {
100+ name : 'Design Review' ,
101+ icon : < RateReviewIcon /> ,
102+ route : routes . CALENDAR
103+ }
104+ ]
105+ } ,
106+ ! onGuestHomePage && {
61107 name : 'Change Requests' ,
62108 icon : < SyncAltIcon /> ,
63109 route : routes . CHANGE_REQUESTS
64110 } ,
65- {
111+ ! onGuestHomePage && {
66112 name : 'Finance' ,
67113 icon : < AttachMoneyIcon /> ,
68114 route : routes . FINANCE ,
@@ -84,29 +130,41 @@ const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: Sid
84130 }
85131 ]
86132 } ,
87- {
88- name : 'Teams' ,
89- icon : < GroupIcon /> ,
90- route : routes . TEAMS
91- } ,
92- {
133+ ! onGuestHomePage
134+ ? {
135+ name : 'Teams' ,
136+ icon : < GroupIcon /> ,
137+ route : routes . TEAMS
138+ }
139+ : {
140+ name : 'Divisions' ,
141+ icon : < GroupIcon /> ,
142+ route : routes . TEAMS ,
143+ subItems : allTeams
144+ } ,
145+ ! onGuestHomePage && {
93146 name : 'Calendar' ,
94147 icon : < CalendarTodayIcon /> ,
95148 route : routes . CALENDAR
96149 } ,
97- {
150+ ! onGuestHomePage && {
98151 name : 'Retrospective' ,
99152 icon : < Cached /> ,
100153 route : routes . RETROSPECTIVE
101154 } ,
155+ onGuestHomePage && {
156+ name : 'Sponsors' ,
157+ icon : < VolunteerActivismIcon /> ,
158+ route : routes . RETROSPECTIVE
159+ } ,
102160 {
103161 name : 'Info' ,
104162 icon : < QuestionMarkIcon /> ,
105163 route : routes . INFO
106164 }
107- ] ;
165+ ] . filter ( Boolean ) as LinkItem [ ] ;
108166
109- if ( ! isGuest ( user . role ) ) {
167+ if ( ! isGuest ( user . role ) && ! onGuestHomePage ) {
110168 memberLinkItems . splice ( 6 , 0 , {
111169 name : 'Statistics' ,
112170 icon : < BarChartIcon /> ,
0 commit comments