Skip to content

Commit c635232

Browse files
3872 fixed subteams tab
1 parent 234ea7b commit c635232

2 files changed

Lines changed: 35 additions & 26 deletions

File tree

src/frontend/src/layouts/Sidebar/Sidebar.tsx

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,14 @@
44
*/
55

66
import { routes } from '../../utils/routes';
7-
import { Route } from 'react-router-dom';
8-
import TeamSpecificPage from '../../pages/TeamsPage/TeamSpecificPage';
97
import { LinkItem } from '../../utils/types';
108
import styles from '../../stylesheets/layouts/sidebar/sidebar.module.css';
119
import { Typography, Box, IconButton, Divider } from '@mui/material';
1210
import HomeIcon from '@mui/icons-material/Home';
1311
import AlignHorizontalLeftIcon from '@mui/icons-material/AlignHorizontalLeft';
1412
import RateReviewIcon from '@mui/icons-material/RateReview';
1513
import 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';
1914
import VolunteerActivismIcon from '@mui/icons-material/VolunteerActivism';
20-
import BusinessCenterIcon from '@mui/icons-material/BusinessCenter';
2115
import FolderIcon from '@mui/icons-material/Folder';
2216
import SyncAltIcon from '@mui/icons-material/SyncAlt';
2317
import GroupIcon from '@mui/icons-material/Group';
@@ -28,10 +22,14 @@ import NavPageLink from './NavPageLink';
2822
import NERDrawer from '../../components/NERDrawer';
2923
import NavUserMenu from '../PageTitle/NavUserMenu';
3024
import DrawerHeader from '../../components/DrawerHeader';
31-
import { Cached, ChevronLeft, ChevronRight, NotListedLocation } from '@mui/icons-material';
25+
import { Cached, ChevronLeft, ChevronRight } from '@mui/icons-material';
3226
import { 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';
3533
import BarChartIcon from '@mui/icons-material/BarChart';
3634
import { useCurrentUser } from '../../hooks/users.hooks';
3735
import 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
{

src/frontend/src/pages/HomePage/IntroGuestHomePage.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,12 @@ import { useCurrentUser } from '../../hooks/users.hooks';
77
import { useEffect } from 'react';
88
import { useHomePageContext } from '../../app/HomePageContext';
99
import { useCurrentOrganization } from '../../hooks/organizations.hooks';
10-
import LoadingIndicator from '../../components/LoadingIndicator';
1110
import ErrorPage from '../ErrorPage';
12-
import { useGetImageUrl } from '../../hooks/onboarding.hook';
1311

1412
const IntroGuestHomePage = () => {
1513
const user = useCurrentUser();
1614
const history = useHistory();
17-
const {
18-
data: organization,
19-
isLoading: organizationIsLoading,
20-
isError: organizationIsError,
21-
error: organizationError
22-
} = useCurrentOrganization();
15+
const { isError: organizationIsError, error: organizationError } = useCurrentOrganization();
2316
const { setCurrentHomePage } = useHomePageContext();
2417

2518
// const {

0 commit comments

Comments
 (0)