Skip to content

Commit

Permalink
feat: 어드민 아닐시 리다렉 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
healim01 committed Dec 4, 2024
1 parent 2551e8e commit 0d63af1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion frontend/src/pages/AdminPage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import styled from '@emotion/styled';
import { Link } from 'react-router-dom';
import { useEffect } from 'react';
import { Link, useNavigate } from 'react-router-dom';

import { ROUTE_PATH } from '@/constants/routePath';
import useUserQuery from '@/hooks/query/useUserQuery';
import useToast from '@/hooks/useToast';
import { boxShadowSpread, flexRow, title2, title3 } from '@/styles/common';

const AdminPage = () => {
const { data: user } = useUserQuery();
const { showToast } = useToast();
const navigate = useNavigate();

useEffect(() => {
if (user?.userType !== 'ADMIN') {
showToast({ message: '해당 페이지 접근 권한이 없습니다.', type: 'error' });
navigate(ROUTE_PATH.root);
}
}, []);

return (
<S.PageWrapper>
<S.QuestionBox>
Expand Down

0 comments on commit 0d63af1

Please sign in to comment.