@@ -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' ;
@@ -50,19 +51,18 @@ const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: Sid
5051 const { onPNMHomePage, onOnboardingHomePage } = useHomePageContext ( ) ;
5152 const user = useCurrentUser ( ) ;
5253 const { onGuestHomePage } = useHomePageContext ( ) ;
53- // const { isError: teamsError, error: teamsErrorMsg, data: teams } = useAllTeamTypes();
54+ const { isError : teamsError , error : teamsErrorMsg , data : teams } = useAllTeamTypes ( ) ;
5455
55- // To be uncommented once guest divisions pages are developed
56- // const allTeams: LinkItem[] = (teams ?? []).map((team: TeamType) => {
57- // const IconComponent = MuiIcons[(team.iconName in MuiIcons ? team.iconName : 'Circle') as keyof typeof MuiIcons];
58- // return {
59- // name: team.name,
60- // icon: <IconComponent />,
61- // route: routes.TEAMS + '/' + team.teamTypeId
62- // };
63- // });
56+ const allTeams : LinkItem [ ] = ( teams ?? [ ] ) . map ( ( team : TeamType ) => {
57+ const IconComponent = MuiIcons [ ( team . iconName in MuiIcons ? team . iconName : 'Circle' ) as keyof typeof MuiIcons ] ;
58+ return {
59+ name : team . name ,
60+ icon : < IconComponent /> ,
61+ route : routes . TEAMS + '/' + team . teamTypeId
62+ } ;
63+ } ) ;
6464
65- // if (teamsError) return <ErrorPage error={teamsErrorMsg} />;
65+ if ( teamsError ) return < ErrorPage error = { teamsErrorMsg } /> ;
6666 const memberLinkItems : LinkItem [ ] = [
6767 {
6868 name : 'Home' ,
@@ -136,23 +136,18 @@ const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: Sid
136136 } ,
137137
138138 // Teams tab here to be replaced with below code once guest divisions is developed
139- ! onGuestHomePage && {
140- name : 'Teams' ,
141- icon : < GroupIcon /> ,
142- route : routes . TEAMS
143- } ,
144- // !onGuestHomePage
145- // ? {
146- // name: 'Teams',
147- // icon: <GroupIcon />,
148- // route: routes.TEAMS
149- // }
150- // : {
151- // name: 'Divisions',
152- // icon: <GroupIcon />,
153- // route: routes.TEAMS,
154- // subItems: allTeams
155- // },
139+ ! onGuestHomePage
140+ ? {
141+ name : 'Teams' ,
142+ icon : < GroupIcon /> ,
143+ route : routes . TEAMS
144+ }
145+ : {
146+ name : 'Divisions' ,
147+ icon : < GroupIcon /> ,
148+ route : routes . TEAMS ,
149+ subItems : allTeams
150+ } ,
156151 ! onGuestHomePage && {
157152 name : 'Calendar' ,
158153 icon : < CalendarTodayIcon /> ,
0 commit comments