44 */
55
66import { routes } from '../../utils/routes' ;
7- import { Route } from 'react-router-dom' ;
8- import TeamSpecificPage from '../../pages/TeamsPage/TeamSpecificPage' ;
97import { LinkItem } from '../../utils/types' ;
108import styles from '../../stylesheets/layouts/sidebar/sidebar.module.css' ;
119import { Typography , Box , IconButton , Divider } from '@mui/material' ;
1210import HomeIcon from '@mui/icons-material/Home' ;
1311import AlignHorizontalLeftIcon from '@mui/icons-material/AlignHorizontalLeft' ;
1412import RateReviewIcon from '@mui/icons-material/RateReview' ;
1513import DashboardIcon from '@mui/icons-material/Dashboard' ;
16- import ConstructionIcon from '@mui/icons-material/Construction' ;
17- import BoltIcon from '@mui/icons-material/Bolt' ;
18- import CodeIcon from '@mui/icons-material/Code' ;
1914import VolunteerActivismIcon from '@mui/icons-material/VolunteerActivism' ;
20- import BusinessCenterIcon from '@mui/icons-material/BusinessCenter' ;
2115import FolderIcon from '@mui/icons-material/Folder' ;
2216import SyncAltIcon from '@mui/icons-material/SyncAlt' ;
2317import GroupIcon from '@mui/icons-material/Group' ;
@@ -28,10 +22,14 @@ import NavPageLink from './NavPageLink';
2822import NERDrawer from '../../components/NERDrawer' ;
2923import NavUserMenu from '../PageTitle/NavUserMenu' ;
3024import DrawerHeader from '../../components/DrawerHeader' ;
31- import { Cached , ChevronLeft , ChevronRight , NotListedLocation } from '@mui/icons-material' ;
25+ import { Cached , ChevronLeft , ChevronRight } from '@mui/icons-material' ;
3226import { useHomePageContext } from '../../app/HomePageContext' ;
33- import { isGuest } from 'shared' ;
34- import { getAllTeams } from '../../apis/teams.api' ;
27+ import { isGuest , TeamType } from 'shared' ;
28+ import { getAllTeamTypes } from '../../apis/team-types.api' ;
29+ import ConstructionIcon from '@mui/icons-material/Construction' ;
30+ import ElectricBoltIcon from '@mui/icons-material/ElectricBolt' ;
31+ import CodeIcon from '@mui/icons-material/Code' ;
32+ import WorkIcon from '@mui/icons-material/Work' ;
3533import BarChartIcon from '@mui/icons-material/BarChart' ;
3634import { useCurrentUser } from '../../hooks/users.hooks' ;
3735import QueryStatsIcon from '@mui/icons-material/QueryStats' ;
@@ -53,15 +51,33 @@ const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: Sid
5351 const { onGuestHomePage } = useHomePageContext ( ) ;
5452 const [ allTeams , setAllTeams ] = useState < LinkItem [ ] > ( [ ] ) ;
5553
56- getAllTeams ( ) . then ( ( response ) => {
57- setAllTeams (
58- response . data . map ( ( team ) => ( {
59- name : team . teamName ,
60- icon : undefined ,
61- route : routes . TEAMS + '/' + team . teamId
62- } ) )
63- ) ;
64- } ) ;
54+ const getIcon = ( iconName : string ) => {
55+ const icons : { [ key : string ] : React . ComponentType } = {
56+ ConstructionIcon,
57+ CodeIcon,
58+ ElectricBoltIcon,
59+ WorkIcon
60+ } ;
61+ const Icon = icons [ iconName ] ;
62+ return Icon ? < Icon /> : undefined ;
63+ } ;
64+
65+ useEffect ( ( ) => {
66+ getAllTeamTypes ( )
67+ . then ( ( response ) => {
68+ console . log ( 'All teams from API:' , response . data ) ;
69+ setAllTeams (
70+ response . data . map ( ( team : TeamType ) => ( {
71+ name : team . name ,
72+ icon : getIcon ( team . iconName ) ,
73+ route : routes . TEAMS + '/' + team . teamTypeId
74+ } ) )
75+ ) ;
76+ } )
77+ . catch ( ( error ) => {
78+ console . log ( "Teams couldn't load " + error ) ;
79+ } ) ;
80+ } , [ ] ) ;
6581
6682 const memberLinkItems : LinkItem [ ] = [
6783 {
0 commit comments