@@ -27,9 +27,10 @@ import { useHomePageContext } from '../../app/HomePageContext';
2727// once divisions developed, import TeamType from shared
2828import { isGuest } from 'shared' ;
2929// To be uncommented after divisions page is developed
30- // import * as MuiIcons from '@mui/icons-material';
31- // import { useAllTeamTypes } from '../../hooks/team-types.hooks';
32- // import ErrorPage from '../../pages/ErrorPage';
30+ import * as MuiIcons from '@mui/icons-material' ;
31+ import { useAllTeamTypes } from '../../hooks/team-types.hooks' ;
32+ import { TeamType } from 'shared' ;
33+ import ErrorPage from '../../pages/ErrorPage' ;
3334import BarChartIcon from '@mui/icons-material/BarChart' ;
3435import { useCurrentUser } from '../../hooks/users.hooks' ;
3536import QueryStatsIcon from '@mui/icons-material/QueryStats' ;
@@ -52,19 +53,18 @@ const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: Sid
5253 const { onPNMHomePage, onOnboardingHomePage } = useHomePageContext ( ) ;
5354 const user = useCurrentUser ( ) ;
5455 const { onGuestHomePage } = useHomePageContext ( ) ;
55- // const { isError: teamsError, error: teamsErrorMsg, data: teams } = useAllTeamTypes();
56+ const { isError : teamsError , error : teamsErrorMsg , data : teams } = useAllTeamTypes ( ) ;
5657
57- // To be uncommented once guest divisions pages are developed
58- // const allTeams: LinkItem[] = (teams ?? []).map((team: TeamType) => {
59- // const IconComponent = MuiIcons[(team.iconName in MuiIcons ? team.iconName : 'Circle') as keyof typeof MuiIcons];
60- // return {
61- // name: team.name,
62- // icon: <IconComponent />,
63- // route: routes.TEAMS + '/' + team.teamTypeId
64- // };
65- // });
58+ const allTeams : LinkItem [ ] = ( teams ?? [ ] ) . map ( ( team : TeamType ) => {
59+ const IconComponent = MuiIcons [ ( team . iconName in MuiIcons ? team . iconName : 'Circle' ) as keyof typeof MuiIcons ] ;
60+ return {
61+ name : team . name ,
62+ icon : < IconComponent /> ,
63+ route : routes . TEAMS + '/' + team . teamTypeId
64+ } ;
65+ } ) ;
6666
67- // if (teamsError) return <ErrorPage error={teamsErrorMsg} />;
67+ if ( teamsError ) return < ErrorPage error = { teamsErrorMsg } /> ;
6868 const memberLinkItems : LinkItem [ ] = [
6969 {
7070 name : 'Home' ,
@@ -138,23 +138,18 @@ const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: Sid
138138 } ,
139139
140140 // Teams tab here to be replaced with below code once guest divisions is developed
141- ! onGuestHomePage && {
142- name : 'Teams' ,
143- icon : < GroupIcon /> ,
144- route : routes . TEAMS
145- } ,
146- // !onGuestHomePage
147- // ? {
148- // name: 'Teams',
149- // icon: <GroupIcon />,
150- // route: routes.TEAMS
151- // }
152- // : {
153- // name: 'Divisions',
154- // icon: <GroupIcon />,
155- // route: routes.TEAMS,
156- // subItems: allTeams
157- // },
141+ ! onGuestHomePage
142+ ? {
143+ name : 'Teams' ,
144+ icon : < GroupIcon /> ,
145+ route : routes . TEAMS
146+ }
147+ : {
148+ name : 'Divisions' ,
149+ icon : < GroupIcon /> ,
150+ route : routes . TEAMS ,
151+ subItems : allTeams
152+ } ,
158153 ! onGuestHomePage && {
159154 name : 'Calendar' ,
160155 icon : < CalendarTodayIcon /> ,
0 commit comments