11import { useEffect , useState } from 'react' ;
2- import { useParams } from 'react-router-dom' ;
2+ import { useNavigate , useParams } from 'react-router-dom' ;
33import * as Styled from '@/styles/PageContainer.styles' ;
44import Header from '@/components/common/Header/Header' ;
55import BackNavigationBar from '@/pages/ClubDetailPage/components/BackNavigationBar/BackNavigationBar' ;
@@ -61,8 +61,24 @@ const ClubDetailPage = () => {
6161 const { sectionRefs, scrollToSection } = useAutoScroll ( ) ;
6262 const [ showHeader , setShowHeader ] = useState ( window . innerWidth > 500 ) ;
6363
64+ const navigate = useNavigate ( ) ;
65+ const [ blockState , setBlockState ] = useState <
66+ 'checking' | 'blocked' | 'allowed'
67+ > ( 'checking' ) ;
6468 const { data : clubDetail , error } = useGetClubDetail ( clubId || '' ) ;
6569
70+ useEffect ( ( ) => {
71+ if ( ! clubDetail ) return ;
72+
73+ if ( notJoinedClubNames . includes ( clubDetail ?. name || '' ) ) {
74+ setBlockState ( 'blocked' ) ;
75+ alert ( '참여하지 않는 동아리입니다.' ) ;
76+ navigate ( '/' , { replace : true } ) ;
77+ } else {
78+ setBlockState ( 'allowed' ) ;
79+ }
80+ } , [ clubDetail , navigate ] ) ;
81+
6682 useEffect ( ( ) => {
6783 const handleResize = ( ) => {
6884 setShowHeader ( window . innerWidth > 500 ) ;
@@ -74,7 +90,7 @@ const ClubDetailPage = () => {
7490
7591 useTrackPageView ( `ClubDetailPage` , clubDetail ?. name ) ;
7692
77- if ( ! clubDetail ) {
93+ if ( ! clubDetail || blockState !== 'allowed' ) {
7894 return null ;
7995 }
8096
0 commit comments