@@ -13,18 +13,30 @@ import * as styles from './testPage.css';
1313import { usePostTestResult } from '@apis/test' ;
1414import { useRouter } from 'next/navigation' ;
1515import TestHeader from '@components/test/testHeader/TestHeader' ;
16+ import { getCookie } from 'cookies-next' ;
17+ import ModalContainer from '@components/common/modal/ModalContainer' ;
1618
1719const TestPage = ( ) => {
1820 const router = useRouter ( ) ;
1921 const [ selections , setSelections ] = useState < string [ ] > ( [ ] ) ;
22+ const [ isModalOpen , setIsModalOpen ] = useState ( false ) ;
2023 const steps = [ 'START' , ...TEST_STEPS . map ( ( step ) => step . id ) ] ;
24+ const hasType = getCookie ( 'hasType' ) ;
2125
2226 const { Funnel, Step, nextStep, prevStep, currentStep } = useFunnel ( steps ) ;
2327 const progressStep = steps . indexOf ( currentStep ) ;
2428
2529 const { mutate, isPending, isSuccess } = usePostTestResult ( ) ;
2630 const isLoading = isPending || isSuccess ;
2731
32+ const handleStartClick = ( ) => {
33+ if ( hasType ) {
34+ setIsModalOpen ( true ) ;
35+ } else {
36+ nextStep ( ) ;
37+ }
38+ } ;
39+
2840 const handleSelect = ( choice : string ) => {
2941 const currentStepIndex = steps . indexOf ( currentStep ) - 1 ;
3042
@@ -72,7 +84,7 @@ const TestPage = () => {
7284 < Funnel steps = { steps } >
7385 { [
7486 < Step key = "START" name = "START" >
75- < TestStart onClick = { nextStep } />
87+ < TestStart onClick = { handleStartClick } />
7688 </ Step > ,
7789
7890 ...TEST_STEPS . map ( ( { id, title, option1, option2 } ) => (
@@ -89,6 +101,21 @@ const TestPage = () => {
89101 </ Funnel >
90102 </ div >
91103 ) }
104+
105+ { isModalOpen && (
106+ < ModalContainer
107+ modalTitle = "성향테스트를 이미 받으셨어요!"
108+ modalBody = "다시 받고싶으시다면 ‘다시하기’를 눌러주세요"
109+ isOpen = { isModalOpen }
110+ handleClose = { ( ) => setIsModalOpen ( false ) }
111+ handleSubmit = { ( ) => {
112+ setIsModalOpen ( false ) ;
113+ nextStep ( ) ;
114+ } }
115+ leftBtnLabel = "뒤로가기"
116+ rightBtnLabel = "다시하기"
117+ />
118+ ) }
92119 </ div >
93120 ) ;
94121} ;
0 commit comments