Skip to content

Commit

Permalink
added protection to make sure that only registered frosh can access f…
Browse files Browse the repository at this point in the history
…rosh olympiks page
  • Loading branch information
gaurikam2003 committed Aug 22, 2024
1 parent e33ad8a commit 13a4725
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
13 changes: 12 additions & 1 deletion client/src/pages/FroshOlympiks/FroshOlympiks.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import React, { useState, useEffect, useContext } from 'react';
import './FroshOlympiks.scss';
import { Link } from 'react-router-dom';
import { Link, useNavigate } from 'react-router-dom';
import { registeredSelector, userSelector } from '../../state/user/userSlice';
import { useSelector } from 'react-redux';
import { ScheduleComponent } from '../../components/schedule/ScheduleOlympiks/ScheduleOlympiks';
import useAxios from '../../hooks/useAxios';
const { axios } = useAxios();

export const FroshOlympiks = () => {
const navigate = useNavigate();
const isRegistered = useSelector(registeredSelector);

useEffect(() => {
if (!isRegistered) {
navigate('/profile');
}
}, [isRegistered]);

return (
<>
<OlympiksSchedule />
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/Profile/PageProfileFrosh.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const PageProfileFrosh = () => {
<div className="profile-info-row-right">
{user?.attendingScunt === true ? <ProfilePageFroshScuntMessage /> : null}
<ProfilePageRetreat />
<ProfilePageFroshOlympiks />
{isRegistered ? <ProfilePageFroshOlympiks /> : null}
{/* <ProfilePageNitelife /> */}
<ProfilePageInstagrams />
<ProfilePageAnnouncements />
Expand Down
6 changes: 5 additions & 1 deletion client/src/util/pages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ export const pages = {
},
{
label: 'frosh-olympiks',
component: <FroshOlympiks />,
component: (
<AuthorizedPage>
<FroshOlympiks />
</AuthorizedPage>
),
path: '/frosh-olympiks',
includeFooter: true,
},
Expand Down

0 comments on commit 13a4725

Please sign in to comment.