Skip to content

Commit 02bd1c8

Browse files
authored
Merge pull request #4179 from Northeastern-Electric-Racing/#4100-sponsors-page
#4100 sponsors page
2 parents c9d1465 + df961e3 commit 02bd1c8

4 files changed

Lines changed: 87 additions & 13 deletions

File tree

src/frontend/src/app/AppAuthenticated.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import RetrospectiveGanttChartPage from '../pages/RetrospectivePage/Retrospectiv
3030
import Calendar from '../pages/CalendarPage/Calendar';
3131
import GuestEventPage from '../pages/GuestEventPage/GuestEventPage';
3232
import GuestInfoPage from '../pages/GuestInfoPage/GuestInfoPage';
33+
import GuestSponsorsPage from '../pages/GuestSponsorsPage/GuestSponsorsPage';
3334
import ProjectManagementPage from '../pages/ProjectManagementPage/ProjectManagementPage';
3435
import SidebarLayout from '../layouts/SidebarLayout';
3536

@@ -83,6 +84,7 @@ const AppAuthenticated: React.FC<AppAuthenticatedProps> = ({ userId, userRole })
8384
<Route path={routes.RETROSPECTIVE} component={RetrospectiveGanttChartPage} />
8485
<Route path={routes.PROJECT_MANAGEMENT} component={ProjectManagementPage} />
8586
<Route path={routes.EVENTS} component={GuestEventPage} />
87+
<Route path={routes.SPONSORS} component={GuestSponsorsPage} />
8688
<Route path={routes.GUEST_INFO} component={GuestInfoPage} />
8789
<Redirect from={routes.BASE} to={routes.HOME} />
8890
<Route path="*" component={PageNotFound} />

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import { Typography, Box, IconButton, Divider } from '@mui/material';
1010
import HomeIcon from '@mui/icons-material/Home';
1111
import AlignHorizontalLeftIcon from '@mui/icons-material/AlignHorizontalLeft';
1212
import DashboardIcon from '@mui/icons-material/Dashboard';
13-
// To be uncommented after guest sponsors page is developed
14-
// import VolunteerActivismIcon from '@mui/icons-material/VolunteerActivism';
13+
import VolunteerActivismIcon from '@mui/icons-material/VolunteerActivism';
1514
import FolderIcon from '@mui/icons-material/Folder';
1615
import SyncAltIcon from '@mui/icons-material/SyncAlt';
1716
import GroupIcon from '@mui/icons-material/Group';
@@ -24,12 +23,9 @@ import NavUserMenu from '../PageTitle/NavUserMenu';
2423
import DrawerHeader from '../../components/DrawerHeader';
2524
import { Cached, ChevronLeft, ChevronRight } from '@mui/icons-material';
2625
import { useHomePageContext } from '../../app/HomePageContext';
27-
// once divisions developed, import TeamType from shared
28-
import { isGuest } from 'shared';
29-
// To be uncommented after divisions page is developed
26+
import { isGuest, TeamType } from 'shared';
3027
import * as MuiIcons from '@mui/icons-material';
3128
import { useAllTeamTypes } from '../../hooks/team-types.hooks';
32-
import { TeamType } from 'shared';
3329
import ErrorPage from '../../pages/ErrorPage';
3430
import BarChartIcon from '@mui/icons-material/BarChart';
3531
import { useCurrentUser } from '../../hooks/users.hooks';
@@ -137,7 +133,6 @@ const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: Sid
137133
]
138134
},
139135

140-
// Teams tab here to be replaced with below code once guest divisions is developed
141136
!onGuestHomePage
142137
? {
143138
name: 'Teams',
@@ -161,12 +156,11 @@ const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: Sid
161156
icon: <Cached />,
162157
route: routes.RETROSPECTIVE
163158
},
164-
// To be uncommented once guest mode sponsors page is developed
165-
// onGuestHomePage && {
166-
// name: 'Sponsors',
167-
// icon: <VolunteerActivismIcon />,
168-
// route: routes.RETROSPECTIVE
169-
// },
159+
onGuestHomePage && {
160+
name: 'Sponsors',
161+
icon: <VolunteerActivismIcon />,
162+
route: routes.SPONSORS
163+
},
170164
{
171165
name: 'Info',
172166
icon: <QuestionMarkIcon />,
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { Typography, useTheme } from '@mui/material';
2+
import LoadingIndicator from '../../components/LoadingIndicator';
3+
import { useGetAllSponsors } from '../../hooks/finance.hooks';
4+
import ErrorPage from '../ErrorPage';
5+
import { Box } from '@mui/system';
6+
import PageLayout from '../../components/PageLayout';
7+
import { useGetImageUrl } from '../../hooks/onboarding.hook';
8+
9+
const SponsorImage: React.FC<{ logoImageId: string; name: string }> = ({ logoImageId, name }) => {
10+
const { data: imageUrl, isLoading, isError, error } = useGetImageUrl(logoImageId);
11+
12+
if (isError) {
13+
return <ErrorPage message={error.message} />;
14+
}
15+
16+
if (!imageUrl || isLoading) {
17+
return <LoadingIndicator />;
18+
}
19+
20+
return (
21+
<Box
22+
sx={{
23+
display: 'flex',
24+
alignItems: 'center',
25+
justifyContent: 'center',
26+
borderRadius: 2,
27+
p: 2,
28+
width: { xs: '100%', sm: 'calc(50% - 8px)', md: 'calc(33.33% - 11px)' }
29+
}}
30+
>
31+
<Box component="img" src={imageUrl} alt={name} sx={{ maxWidth: '100%', maxHeight: 120, objectFit: 'contain' }} />
32+
</Box>
33+
);
34+
};
35+
36+
const GuestSponsorsPage: React.FC = () => {
37+
const theme = useTheme();
38+
const { data: sponsors, isLoading, isError, error } = useGetAllSponsors();
39+
if (isError) {
40+
return <ErrorPage message={error.message} />;
41+
}
42+
43+
if (!sponsors || isLoading) {
44+
return <LoadingIndicator />;
45+
}
46+
47+
const sorted = [...sponsors].sort((a, b) => {
48+
const aVal = a.tier?.minSupportValue ?? -Infinity;
49+
const bVal = b.tier?.minSupportValue ?? -Infinity;
50+
return bVal - aVal;
51+
});
52+
53+
return (
54+
<PageLayout title="Sponsors">
55+
<Box>
56+
<Box sx={{ bgcolor: theme.palette.background.paper, borderRadius: 2, p: 2 }}>
57+
<Typography>
58+
We would not be able to put a competitive car on the track each year without the help of each and every one of
59+
our sponsors. Thank you for your support!
60+
</Typography>
61+
</Box>
62+
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 2, mt: 2 }}>
63+
{sorted.map(
64+
(sponsor) =>
65+
sponsor.logoImageId && (
66+
<SponsorImage key={sponsor.sponsorId} logoImageId={sponsor.logoImageId} name={sponsor.name} />
67+
)
68+
)}
69+
</Box>
70+
</Box>
71+
</PageLayout>
72+
);
73+
};
74+
75+
export default GuestSponsorsPage;

src/frontend/src/utils/routes.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const REIMBURSEMENT_REQUEST_EDIT = REIMBURSEMENT_REQUEST_BY_ID + `/edit`;
2828
const NEW_REIMBURSEMENT_REQUEST = REIMBURSEMENT_REQUESTS + `/my-requests/new`;
2929
const FINANCE_DASHBOARD = FINANCE + `/dashboard`;
3030
const COMPANIES = FINANCE + `/companies`;
31+
const SPONSORS = `/sponsors`;
3132

3233
/**************** Projects Section ****************/
3334
const PROJECTS = `/projects`;
@@ -149,5 +150,7 @@ export const routes = {
149150
EDIT_GRAPH,
150151
GRAPH_COLLECTION_BY_ID,
151152

153+
SPONSORS,
154+
152155
RETROSPECTIVE
153156
};

0 commit comments

Comments
 (0)