11'use client' ;
22
33import { useForm } from 'react-hook-form' ;
4- import { useRouter } from 'next/navigation' ;
54import { InputField } from '@/shared/components/InputField' ;
6- import { SignupDialogButton } from '@/app/signup/SignupDialogButton' ;
7-
8- type CareerYearType = 'NEWBIE' | 'JUNIOR' | 'MID' | 'SENIOR' | 'LEAD' ;
9-
10- // 회원가입 시 필요한 데이터타입
11- interface SignupFormData {
12- email : string ;
13- password : string ;
14- name : string ;
15- jobRoleId : string ;
16- careerYear : '' | CareerYearType ;
17- privacyPolicy : boolean ; // 개인정보수집동의 관련해서 백엔드 저장이 필요할듯?
18- termsOfService : boolean ; // 개인정보수집동의 관련해서 백엔드 저장이 필요할듯?
19- }
5+ import { SignupDialogButton } from '@/app/signup/components/SignupDialogButton' ;
6+ import { SelectJobButtonGroup } from '@/app/signup/components/SelectJobButtonGroup' ;
7+ import { SignupFormData } from '@/app/signup/type' ;
8+ import { useFetchSignUp } from '@/app/signup/hooks/ useFetchSignUp' ;
209
2110const SignUpForm = ( ) => {
22- const router = useRouter ( ) ;
11+ const { isSubmitting , isSignupSuccess , fetchSignUp } = useFetchSignUp ( ) ;
2312 const {
2413 watch,
2514 setValue,
@@ -38,12 +27,8 @@ const SignUpForm = () => {
3827 } ) ;
3928 const jobRoleId = watch ( 'jobRoleId' ) ;
4029
41- const onSubmit = async ( data : SignupFormData ) => {
42- console . log ( 'Form submitted:' , data ) ;
43- } ;
44-
4530 return (
46- < form onSubmit = { handleSubmit ( onSubmit ) } className = "space-y-6 w-full" >
31+ < form className = "space-y-6 w-full" >
4732 < InputField
4833 label = "Email"
4934 type = "email"
@@ -59,7 +44,7 @@ const SignUpForm = () => {
5944 errorMessage = { errors . email ?. message as string }
6045 />
6146 < InputField
62- label = "PW "
47+ label = "비밀번호 "
6348 type = "password"
6449 placeholder = "비밀번호를 입력해주세요."
6550 { ...register ( 'password' , {
@@ -89,35 +74,10 @@ const SignUpForm = () => {
8974
9075 < div className = "space-y-2" >
9176 < label className = "block text-sm font-medium text-gray-300" > 직무</ label >
92- < div className = "flex gap-2" >
93- < button
94- type = "button"
95- className = { `px-4 py-2 rounded-lg ${
96- jobRoleId === 'jobId1' ? 'bg-[#8C7FF7] text-white' : 'bg-[#2C2C2E] text-gray-400'
97- } `}
98- onClick = { ( ) => setValue ( 'jobRoleId' , 'jobId1' , { shouldValidate : true } ) }
99- >
100- 기획
101- </ button >
102- < button
103- type = "button"
104- className = { `px-4 py-2 rounded-lg ${
105- jobRoleId === 'jobId2' ? 'bg-[#8C7FF7] text-white' : 'bg-[#2C2C2E] text-gray-400'
106- } `}
107- onClick = { ( ) => setValue ( 'jobRoleId' , 'jobId2' , { shouldValidate : true } ) }
108- >
109- 디자이너
110- </ button >
111- < button
112- type = "button"
113- className = { `px-4 py-2 rounded-lg ${
114- jobRoleId === 'jobId3' ? 'bg-[#8C7FF7] text-white' : 'bg-[#2C2C2E] text-gray-400'
115- } `}
116- onClick = { ( ) => setValue ( 'jobRoleId' , 'jobId3' , { shouldValidate : true } ) }
117- >
118- 개발자
119- </ button >
120- </ div >
77+ < SelectJobButtonGroup
78+ selectedJobId = { jobRoleId }
79+ onJobSelect = { jobId => setValue ( 'jobRoleId' , jobId , { shouldValidate : true } ) }
80+ />
12181 { errors . jobRoleId && < p className = "text-xs text-red-500" > { errors . jobRoleId . message as string } </ p > }
12282 </ div >
12383
@@ -157,7 +117,12 @@ const SignUpForm = () => {
157117 </ label >
158118 { errors . termsOfService && < p className = "text-xs text-red-500" > { errors . termsOfService . message as string } </ p > }
159119 </ div >
160- < SignupDialogButton isValid = { isValid } />
120+ < SignupDialogButton
121+ isValid = { isValid }
122+ isSubmitting = { isSubmitting }
123+ isSignupSuccess = { isSignupSuccess }
124+ onClick = { handleSubmit ( fetchSignUp ) }
125+ />
161126 </ form >
162127 ) ;
163128} ;
0 commit comments