@@ -3,9 +3,10 @@ import { ReactNode, useEffect, useState } from 'react'
33
44import { ClientModalData } from '@/src/lib/constants/modal_data'
55import { ROUTES } from '@/src/lib/constants/route'
6+ import useAuthStore from '@/src/lib/context/authContext'
67import useModal from '@/src/lib/hooks/useModal'
78import { toast } from '@/src/lib/hooks/useToast'
8- import { RegisterType } from '@/src/lib/HTTP/api/auth/api'
9+ import { RegisterType , VerifyPDFType } from '@/src/lib/HTTP/api/auth/api'
910import { useMutationStore } from '@/src/lib/HTTP/api/tanstack-query'
1011import { NullableObject } from '@/src/lib/utils/typeUtils'
1112
@@ -16,8 +17,10 @@ import { Label } from '../../ui/label'
1617interface RegisterCheckProps { }
1718const RegisterCheck = ( { } : RegisterCheckProps ) : ReactNode => {
1819 const router = useRouter ( )
20+ const { studentId, name } = useAuthStore ( )
1921 const { isOpen, modalData, Modal, openModal } = useModal ( )
2022
23+ const [ pdfFile , setPdfFile ] = useState < File > ( )
2124 // Constants
2225 const INIT_INFO : NullableObject < RegisterType > = { student_name : null , student_id : null , password : null , email : null }
2326
@@ -33,6 +36,14 @@ const RegisterCheck = ({}: RegisterCheckProps): ReactNode => {
3336 } ) )
3437 }
3538
39+ const handleFileChange = ( e : any ) => {
40+ setPdfFile ( e . target . files [ 0 ] )
41+ }
42+
43+ useEffect ( ( ) => {
44+ console . log ( pdfFile )
45+ } , [ pdfFile ] )
46+
3647 useEffect ( ( ) => {
3748 if ( ! Object . values ( userInfo ) . includes ( null ) ) {
3849 setIsDone ( true )
@@ -42,6 +53,8 @@ const RegisterCheck = ({}: RegisterCheckProps): ReactNode => {
4253 } , [ userInfo ] )
4354
4455 // Mutations
56+ const { mutate : VerifyPDFMutate , isPending : isVerifying } = useMutationStore < VerifyPDFType > ( [ 'verify_pdf' ] )
57+
4558 const { mutate : RegisterMutate , isPending : isRegistering } = useMutationStore < RegisterType > ( [ 'register' ] )
4659
4760 const registerHandler = ( ) => {
@@ -92,6 +105,22 @@ const RegisterCheck = ({}: RegisterCheckProps): ReactNode => {
92105 } ,
93106 } )
94107 }
108+ const testVerifyHandle = ( ) => {
109+ if ( pdfFile ) {
110+ VerifyPDFMutate (
111+ {
112+ student_id : '2019311945' ,
113+ name : '김지호' ,
114+ pdf : pdfFile ,
115+ } ,
116+ {
117+ onSuccess ( data , variables , context ) {
118+ console . log ( data )
119+ } ,
120+ } ,
121+ )
122+ }
123+ }
95124
96125 return (
97126 < >
@@ -152,6 +181,19 @@ const RegisterCheck = ({}: RegisterCheckProps): ReactNode => {
152181 />
153182 </ div >
154183
184+ < div className = 'flex w-full items-center justify-start gap-2' >
185+ < Label htmlFor = 'file' className = 'w-20 font-bold text-swBlack' >
186+ 재학증명서
187+ </ Label >
188+ < Input
189+ type = 'file'
190+ id = 'file'
191+ placeholder = '재학증명서 파일을 첨부해주세요'
192+ onChange = { handleFileChange }
193+ className = 'flex h-12 items-center justify-start'
194+ />
195+ </ div >
196+ < button onClick = { testVerifyHandle } > 테스트</ button >
155197 < Button onClick = { registerHandler } variant = { isDone ? 'swBlack' : 'swBlackDisabled' } disabled = { ! isDone } className = 'w-full' >
156198 가입하기
157199 </ Button >
0 commit comments