Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor] Reduce codebase down to a bare minimum & remove unused dependencies. #107

Closed
wants to merge 8 commits into from
22 changes: 1 addition & 21 deletions api/schema.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
import { CategoryResponse, DataAttributes } from '../types';
import { APIResponseBlog } from '../types/Blogs';
import { DataAttributes } from '../types';
import { APIResponseEvent } from '../types/Events';
import { MemberResponse } from '../types/Members';
import { APIResponseSponsor } from '../types/Sponsors';

import { CustomFetch } from './useFetch';

const blogs = (customFetch: CustomFetch) =>
({
blogsList: async () => {
const res = await customFetch('CMS', 'blogs?populate=*');
return res.data as APIResponseBlog;
},
} as const);

const events = (customFetch: CustomFetch) =>
({
eventsList: async () => {
Expand All @@ -29,20 +19,10 @@ const members = (customFetch: CustomFetch) => ({
},
});

const sponsors = (customFetch: CustomFetch) =>
({
sponsorsList: async () => {
const res = await customFetch('CMS', 'sponsors?populate=*');
return res.data as APIResponseSponsor;
},
} as const);

const config = (customFetch: CustomFetch) =>
({
...blogs(customFetch),
...events(customFetch),
...members(customFetch),
...sponsors(customFetch),
} as const);

export default config;
105 changes: 0 additions & 105 deletions components/Blogs/BlogHighlightSection.tsx

This file was deleted.

74 changes: 0 additions & 74 deletions components/Blogs/BlogListSection.tsx

This file was deleted.

23 changes: 1 addition & 22 deletions components/Common/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import Tabs from '@mui/material/Tabs';
import Typography from '@mui/material/Typography';

import Logo from '@public/MCSS.svg';
import { getAllBlogs } from '@store/blogSlice';
import { getAllEvents } from '@store/eventSlice';
import { useAppDispatch, useAppSelector } from '@store/hooks';
import { useIsMobile } from '@utils/hooks';
import classNames from 'classnames';
import useSponsors from 'hooks/useSponsors';
import Image from 'next/image';
import { useRouter } from 'next/router';
import _ from 'underscore';
Expand All @@ -40,34 +38,19 @@ const NavBar: FC = () => {
const [showDrawer, setShowDrawer] = useState(false);
const router = useRouter();
const { events } = useAppSelector((state) => state.events);
const { blogs } = useAppSelector((state) => state.blogs);
const { data: sponsors } = useSponsors();
const links = [
{ label: 'Events', href: '/Events' },
{ label: 'Blogs', href: '/Blogs' },
{ label: 'Sponsors', href: '/Sponsors' },
];
const searchBarWhiteList = ['/Events', '/Blogs', '/Sponsors'];
const searchBarWhiteList = ['/Events'];
const partialRouteMatch = searchBarWhiteList.some((route) => router.pathname.includes(route));
const options = [
...Object.entries(events).map(([id, { title }]) => ({ label: `Event: ${title}`, value: id })),
...Object.entries(blogs).map(([id, { title }]) => ({ label: `Blog: ${title}`, value: id })),
...(sponsors?.data
? Object.entries(sponsors.data).map(([, { id, attributes }]) => ({
label: `Sponsors: ${attributes.title}`,
value: id.toString(),
}))
: []),
];

useEffect(() => {
if (_.isEmpty(events)) {
dispatch(getAllEvents());
}

if (_.isEmpty(blogs)) {
dispatch(getAllBlogs());
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand Down Expand Up @@ -114,10 +97,6 @@ const NavBar: FC = () => {
setValue(selectedOption);
if (selectedOption?.label.includes('Event:')) {
router.push(`/Events/${selectedOption.value}`);
} else if (selectedOption?.label.includes('Blog:')) {
router.push(`/Blogs/${selectedOption.value}`);
} else if (selectedOption?.label.includes('Sponsors:')) {
router.push(`/Sponsors/${selectedOption.value}`);
}
}}
options={options}
Expand Down
2 changes: 0 additions & 2 deletions components/Events/EventHighlightSection.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { FC } from 'react';

import EventOutlinedIcon from '@mui/icons-material/EventOutlined';
import PersonOutlineOutlinedIcon from '@mui/icons-material/PersonOutlineOutlined';
import Button from '@mui/material/Button';

import MaterialCard from '@components/Common/MaterialCard';
import MediaQueryContainer from '@components/Common/MediaQueryContainer';
Expand Down
1 change: 0 additions & 1 deletion components/Events/EventListSection.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { FC } from 'react';

import EventOutlinedIcon from '@mui/icons-material/EventOutlined';
import PersonOutlineOutlinedIcon from '@mui/icons-material/PersonOutlineOutlined';

import MaterialCard from '@components/Common/MaterialCard';
import Tag from '@components/Common/Tag';
Expand Down
Loading
Loading