Skip to content

Commit 06a0a7e

Browse files
committed
#4088 added guest team specific page with mobile responsiveness
1 parent 58b1740 commit 06a0a7e

2 files changed

Lines changed: 113 additions & 2 deletions

File tree

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { Box, Grid, Stack, Typography } from '@mui/material';
2+
import { useSingleTeam } from '../../hooks/teams.hooks';
3+
import { useParams } from 'react-router-dom';
4+
import LoadingIndicator from '../../components/LoadingIndicator';
5+
import ErrorPage from '../ErrorPage';
6+
import PageLayout from '../../components/PageLayout';
7+
import { WbsElementStatus } from 'shared';
8+
import { routes } from '../../utils/routes';
9+
import PersonOutlineOutlinedIcon from '@mui/icons-material/PersonOutlineOutlined';
10+
import GroupOutlinedIcon from '@mui/icons-material/GroupOutlined';
11+
import GroupsOutlinedIcon from '@mui/icons-material/GroupsOutlined';
12+
import GuestProjectsCard from '../GuestProjectsPage/GuestProjectsCard';
13+
14+
interface ParamTypes {
15+
teamId: string;
16+
}
17+
18+
const GuestTeamSpecificPage: React.FC = () => {
19+
const { teamId } = useParams<ParamTypes>();
20+
const { isLoading, isError, data, error } = useSingleTeam(teamId);
21+
22+
if (isError) return <ErrorPage message={error?.message} />;
23+
if (isLoading || !data) return <LoadingIndicator />;
24+
25+
const activeProjects = data.projects.filter((project) => project.status === WbsElementStatus.Active);
26+
27+
const formatNames = (members: { firstName: string; lastName: string }[]) =>
28+
members.map((m) => `${m.firstName} ${m.lastName}`).join(', ');
29+
30+
return (
31+
<PageLayout
32+
title={`${data.teamName}`}
33+
previousPages={
34+
data.teamType
35+
? [
36+
{ name: 'Divisions', route: routes.TEAMS },
37+
{ name: data.teamType.name, route: `${routes.TEAMS}/${data.teamType.teamTypeId}` }
38+
]
39+
: [{ name: 'Divisions', route: routes.TEAMS }]
40+
}
41+
>
42+
<Box sx={{ mb: 3 }}>
43+
<Typography variant="body2" sx={{ color: 'text.secondary', lineHeight: 1.7 }}>
44+
{data.description}
45+
</Typography>
46+
</Box>
47+
<Box sx={{ mb: 3 }}>
48+
<Typography variant="h5" fontWeight={700} sx={{ mb: 2 }}>
49+
People
50+
</Typography>
51+
<Stack spacing={3}>
52+
<Box display="flex" alignItems="flex-start" gap={1.5}>
53+
<PersonOutlineOutlinedIcon sx={{ color: 'text.secondary', mt: 0.25 }} />
54+
<Box>
55+
<Typography variant="subtitle1" fontWeight={700}>
56+
Head
57+
</Typography>
58+
<Typography variant="body2" color="text.secondary">
59+
{data.head.firstName} {data.head.lastName}
60+
</Typography>
61+
</Box>
62+
</Box>
63+
{data.leads && data.leads.length > 0 && (
64+
<Box display="flex" alignItems="flex-start" gap={1.5}>
65+
<GroupOutlinedIcon sx={{ color: 'text.secondary', mt: 0.25 }} />
66+
<Box>
67+
<Typography variant="subtitle1" fontWeight={700}>
68+
Leads
69+
</Typography>
70+
<Typography variant="body2" color="text.secondary">
71+
{formatNames(data.leads)}
72+
</Typography>
73+
</Box>
74+
</Box>
75+
)}
76+
{data.members && data.members.length > 0 && (
77+
<Box display="flex" alignItems="flex-start" gap={1.5}>
78+
<GroupsOutlinedIcon sx={{ color: 'text.secondary', mt: 0.25 }} />
79+
<Box>
80+
<Typography variant="subtitle1" fontWeight={700}>
81+
Members
82+
</Typography>
83+
<Typography variant="body2" color="text.secondary">
84+
{formatNames(data.members)}
85+
</Typography>
86+
</Box>
87+
</Box>
88+
)}
89+
</Stack>
90+
</Box>
91+
<Box sx={{ mb: 3 }}>
92+
<Typography variant="h5" fontWeight={700} sx={{ mb: 2 }}>
93+
Active Projects
94+
</Typography>
95+
<Grid container spacing={2}>
96+
{activeProjects.map((project) => (
97+
<Grid item xs={12} sm={6} md={4} key={project.id}>
98+
<GuestProjectsCard project={{ ...project, teamTypes: [] }} />
99+
</Grid>
100+
))}
101+
</Grid>
102+
</Box>
103+
</PageLayout>
104+
);
105+
};
106+
107+
export default GuestTeamSpecificPage;

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { isGuest } from 'shared';
1313
import { useAllTeamTypes } from '../../hooks/team-types.hooks';
1414
import GuestTeamPage from '../GuestTeamsPage/GuestTeamPage';
1515
import GuestDivisionPage from '../GuestDivisionsPage/GuestDivisionPage';
16+
import GuestTeamSpecificPage from '../GuestTeamsPage/GuestTeamSpecificPage';
1617
import LoadingIndicator from '../../components/LoadingIndicator';
1718
import ErrorPage from '../ErrorPage';
1819

@@ -24,8 +25,11 @@ const TeamOrDivisionPage: React.FC = () => {
2425
if (isTeamsError) return <ErrorPage message={teamsError.message} />;
2526
if (teamsLoading || !teamTypes) return <LoadingIndicator />;
2627

27-
if (isGuest(user.role) && teamTypes?.some((t) => t.teamTypeId === teamId)) {
28-
return <GuestTeamPage teamTypeId={teamId} />;
28+
if (isGuest(user.role)) {
29+
if (teamTypes?.some((t) => t.teamTypeId === teamId)) {
30+
return <GuestTeamPage teamTypeId={teamId} />;
31+
}
32+
return <GuestTeamSpecificPage />;
2933
}
3034
return <TeamSpecificPage />;
3135
};

0 commit comments

Comments
 (0)