Skip to content

Commit 80a34ef

Browse files
authored
MCSS-92: added sponsor page with new react hooks (#94)
1 parent 5003743 commit 80a34ef

22 files changed

+302
-522
lines changed

api/client.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ import {
77
UseQueryOptions,
88
} from '@tanstack/react-query';
99

10-
import {
11-
APITemplate,
12-
ClientQueries,
13-
InferHandlerInput,
14-
QueryPaths,
15-
} from './types';
10+
import { APITemplate, ClientQueries, InferHandlerInput, QueryPaths } from './types';
1611

1712
const validateApiError = () => {
1813
return (apiError: any) => {

api/schema.ts

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,13 @@
11
import { CategoryResponse, DataAttributes } from '../types';
2-
import { APIResponseAcademic } from '../types/Academics';
32
import { APIResponseBlog } from '../types/Blogs';
43
import { APIResponseEvent } from '../types/Events';
54
import { MemberResponse } from '../types/Members';
6-
import { APIResponsePartner } from '../types/Partners';
5+
import { APIResponseSponsor } from '../types/Sponsors';
76

87
import { CustomFetch } from './useFetch';
98

10-
const academics = (customFetch: CustomFetch) =>
11-
({
12-
academicCategoriesList: async () => {
13-
const res = await customFetch('CMS', 'academic-categories');
14-
return res.data as DataAttributes<CategoryResponse>;
15-
},
16-
academicsList: async () => {
17-
const res = await customFetch('CMS', 'academics?populate=*');
18-
return res.data as APIResponseAcademic;
19-
},
20-
});
21-
229
const blogs = (customFetch: CustomFetch) =>
2310
({
24-
blogCategoriesList: async () => {
25-
const res = await customFetch('CMS', 'blog-categories');
26-
return res.data as DataAttributes<CategoryResponse>;
27-
},
2811
blogsList: async () => {
2912
const res = await customFetch('CMS', 'blogs?populate=*');
3013
return res.data as APIResponseBlog;
@@ -33,43 +16,33 @@ const blogs = (customFetch: CustomFetch) =>
3316

3417
const events = (customFetch: CustomFetch) =>
3518
({
36-
eventCategoriesList: async () => {
37-
const res = await customFetch('CMS', 'event-categories');
38-
return res.data as DataAttributes<CategoryResponse>;
39-
},
4019
eventsList: async () => {
4120
const res = await customFetch('CMS', 'events?populate=*');
4221
return res.data as APIResponseEvent;
4322
},
4423
} as const);
4524

46-
const members = (customFetch: CustomFetch) =>
47-
({
48-
membersList: async () => {
49-
const res = await customFetch('CMS', 'team-members?populate=*');
50-
return res.data as DataAttributes<MemberResponse>;
51-
},
52-
});
25+
const members = (customFetch: CustomFetch) => ({
26+
membersList: async () => {
27+
const res = await customFetch('CMS', 'team-members?populate=*');
28+
return res.data as DataAttributes<MemberResponse>;
29+
},
30+
});
5331

54-
const partners = (customFetch: CustomFetch) =>
32+
const sponsors = (customFetch: CustomFetch) =>
5533
({
56-
partnerCategoriesList: async () => {
57-
const res = await customFetch('CMS', 'partner-categories');
58-
return res.data as DataAttributes<CategoryResponse>;
34+
sponsorsList: async () => {
35+
const res = await customFetch('CMS', 'sponsors?populate=*');
36+
return res.data as APIResponseSponsor;
5937
},
60-
partnersList: async () => {
61-
const res = await customFetch('CMS', 'partners?populate=*');
62-
return res.data as APIResponsePartner;
63-
},
64-
});
38+
} as const);
6539

6640
const config = (customFetch: CustomFetch) =>
6741
({
68-
...academics(customFetch),
6942
...blogs(customFetch),
7043
...events(customFetch),
7144
...members(customFetch),
72-
...partners(customFetch),
45+
...sponsors(customFetch),
7346
} as const);
7447

7548
export default config;

components/Academics/AcademicHighlightSection.tsx

Lines changed: 0 additions & 109 deletions
This file was deleted.

components/Academics/AcademicListSection.tsx

Lines changed: 0 additions & 74 deletions
This file was deleted.

components/Common/NavBar.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { getAllEvents } from '@store/eventSlice';
1515
import { useAppDispatch, useAppSelector } from '@store/hooks';
1616
import { useIsMobile } from '@utils/hooks';
1717
import classNames from 'classnames';
18+
import useSponsors from 'hooks/useSponsors';
1819
import Image from 'next/image';
1920
import { useRouter } from 'next/router';
2021
import _ from 'underscore';
@@ -40,15 +41,23 @@ const NavBar: FC = () => {
4041
const router = useRouter();
4142
const { events } = useAppSelector((state) => state.events);
4243
const { blogs } = useAppSelector((state) => state.blogs);
44+
const { data: sponsors } = useSponsors();
4345
const links = [
4446
{ label: 'Events', href: '/Events' },
4547
{ label: 'Blogs', href: '/Blogs' },
48+
{ label: 'Sponsors', href: '/Sponsors' },
4649
];
47-
const searchBarWhiteList = ['/Events', '/Blogs'];
50+
const searchBarWhiteList = ['/Events', '/Blogs', '/Sponsors'];
4851
const partialRouteMatch = searchBarWhiteList.some((route) => router.pathname.includes(route));
4952
const options = [
5053
...Object.entries(events).map(([id, { title }]) => ({ label: `Event: ${title}`, value: id })),
5154
...Object.entries(blogs).map(([id, { title }]) => ({ label: `Blog: ${title}`, value: id })),
55+
...(sponsors?.data
56+
? Object.entries(sponsors.data).map(([, { id, attributes }]) => ({
57+
label: `Sponsors: ${attributes.title}`,
58+
value: id.toString(),
59+
}))
60+
: []),
5261
];
5362

5463
useEffect(() => {
@@ -107,6 +116,8 @@ const NavBar: FC = () => {
107116
router.push(`/Events/${selectedOption.value}`);
108117
} else if (selectedOption?.label.includes('Blog:')) {
109118
router.push(`/Blogs/${selectedOption.value}`);
119+
} else if (selectedOption?.label.includes('Sponsors:')) {
120+
router.push(`/Sponsors/${selectedOption.value}`);
110121
}
111122
}}
112123
options={options}

0 commit comments

Comments
 (0)