Skip to content

Commit 5e596fc

Browse files
committed
Realized I didn't need a route
1 parent aba1b0c commit 5e596fc

6 files changed

Lines changed: 21 additions & 17 deletions

File tree

src/frontend/src/app/AppAuthenticated.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ const AppAuthenticated: React.FC<AppAuthenticatedProps> = ({ userId, userRole })
122122
<Route path={routes.CHANGE_REQUESTS} component={ChangeRequests} />
123123
<Route path={routes.GANTT} component={GanttChartPage} />
124124
<Route path={routes.TEAMS} component={Teams} />
125-
<Route path={routes.DIVISIONS_BY_ID} component={GuestTeamPage} />
126125
<Route path={routes.SETTINGS} component={Settings} />
127126
<Route path={routes.ADMIN_TOOLS} component={AdminTools} />
128127
<Route path={routes.INFO} component={InfoPage} />

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import QueryStatsIcon from '@mui/icons-material/QueryStats';
3838
import CurrencyExchangeIcon from '@mui/icons-material/CurrencyExchange';
3939
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
4040
import { useState } from 'react';
41-
import { sub } from 'date-fns';
4241

4342
interface SidebarProps {
4443
drawerOpen: boolean;
@@ -54,13 +53,12 @@ const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: Sid
5453
const { onGuestHomePage } = useHomePageContext();
5554
const { isError: teamsError, error: teamsErrorMsg, data: teams } = useAllTeamTypes();
5655

57-
// To be uncommented once guest divisions pages are developed
5856
const allTeams: LinkItem[] = (teams ?? []).map((team: TeamType) => {
5957
const IconComponent = MuiIcons[(team.iconName in MuiIcons ? team.iconName : 'Circle') as keyof typeof MuiIcons];
6058
return {
6159
name: team.name,
6260
icon: <IconComponent />,
63-
route: routes.DIVISIONS + '/' + team.teamTypeId
61+
route: routes.TEAMS + '/' + team.teamTypeId
6462
};
6563
});
6664

src/frontend/src/pages/GuestDivisionPage/GuestTeamPage.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ import { Box, useMediaQuery } from '@mui/system';
44
import PageLayout from '../../components/PageLayout';
55
import GuestSubteamCard from './GuestSubteamCard';
66
import { useTeamsByTypeId } from '../../hooks/teams.hooks';
7-
import { useParams } from 'react-router-dom';
87

9-
interface ParamTypes {
8+
interface GuestTeamPageProps {
109
teamTypeId: string;
1110
}
1211

13-
const GuestTeamPage: React.FC = () => {
12+
const GuestTeamPage: React.FC<GuestTeamPageProps> = ({ teamTypeId }) => {
1413
const isMobilePortrait = useMediaQuery('(max-width:480px)');
15-
const { teamTypeId } = useParams<ParamTypes>();
1614
const { isLoading: teamsIsLoading, isError: teamsIsError, data: teams, error: teamsError } = useTeamsByTypeId(teamTypeId);
1715

1816
if (teamsIsLoading || !teams) return <LoadingIndicator />;

src/frontend/src/pages/TeamsPage/TeamSpecificPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ const TeamSpecificPage: React.FC = () => {
196196
}
197197
previousPages={
198198
isGuest(user.role) && data.teamType
199-
? [{ name: data.teamType.name, route: `${routes.DIVISIONS}/${data.teamType.teamTypeId}` }]
199+
? [{ name: data.teamType.name, route: `${routes.TEAMS}/${data.teamType.teamTypeId}` }]
200200
: [{ name: 'Teams', route: routes.TEAMS }]
201201
}
202202
>

src/frontend/src/pages/TeamsPage/Teams.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,27 @@ import { Route, Switch } from 'react-router-dom';
77
import { routes } from '../../utils/routes';
88
import TeamsPage from './TeamsPage';
99
import TeamSpecificPage from './TeamSpecificPage';
10+
import { useParams } from 'react-router-dom';
11+
import { useCurrentUser } from '../../hooks/users.hooks';
12+
import { isGuest } from 'shared';
13+
import { useAllTeamTypes } from '../../hooks/team-types.hooks';
14+
import GuestTeamPage from '../GuestDivisionPage/GuestTeamPage';
15+
16+
const TeamOrDivisionPage: React.FC = () => {
17+
const { teamId } = useParams<{ teamId: string }>();
18+
const user = useCurrentUser();
19+
const { data: teamTypes } = useAllTeamTypes();
20+
21+
if (isGuest(user.role) && teamTypes?.some((t) => t.teamTypeId === teamId)) {
22+
return <GuestTeamPage teamTypeId={teamId} />;
23+
}
24+
return <TeamSpecificPage />;
25+
};
1026

1127
const Teams: React.FC = () => {
1228
return (
1329
<Switch>
14-
<Route path={routes.TEAMS_BY_ID} component={TeamSpecificPage} />
30+
<Route path={routes.TEAMS_BY_ID} component={TeamOrDivisionPage} />
1531
<Route path={routes.TEAMS} component={TeamsPage} />
1632
</Switch>
1733
);

src/frontend/src/utils/routes.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ const PROJECT_PART = PROJECTS_BY_WBS + '/part/:indexNum';
4141
const TEAMS = `/teams`;
4242
const TEAMS_BY_ID = TEAMS + `/:teamId`;
4343

44-
/**************** Divisions Section ***************/
45-
const DIVISIONS = `/divisions`;
46-
const DIVISIONS_BY_ID = DIVISIONS + `/:teamTypeId`;
47-
4844
/**************** Change Requests Section ****************/
4945
const CHANGE_REQUESTS = `/change-requests`;
5046
const ALL_CHANGE_REQUESTS = CHANGE_REQUESTS + `/all`;
@@ -100,9 +96,6 @@ export const routes = {
10096
TEAMS,
10197
TEAMS_BY_ID,
10298

103-
DIVISIONS,
104-
DIVISIONS_BY_ID,
105-
10699
GANTT,
107100

108101
PROJECTS,

0 commit comments

Comments
 (0)