@@ -55,20 +55,9 @@ const emailValid = (email) => {
5555 return reg . test ( email ) ;
5656} ;
5757
58- const SignupForm = ( {
59- onSubmit,
60- inValidEmail = false ,
61- inValidPassword = false ,
62- inValidFullName = false ,
63- inValidPasswordCheck = false ,
64- } ) => {
65- const [ currentEmailInvalid , setEmailInvalid ] = useState ( inValidEmail ) ;
66- const [ currentPasswordInvalid , setPasswordInvalid ] = useState ( inValidPassword ) ;
67- const [ currentPasswordCheckInvalid , setPasswordCheckInvalid ] = useState ( inValidPasswordCheck ) ;
68- const [ currentFullNameInvalid , setFullNameInvalid ] = useState ( inValidFullName ) ;
58+ const SignupForm = ( { onSubmit } ) => {
6959 const {
7060 values,
71- errors,
7261 handleChange,
7362 handleSubmit,
7463 errorPassword,
@@ -80,37 +69,28 @@ const SignupForm = ({
8069 initialValues : {
8170 email : '' ,
8271 password : '' ,
72+ fullame : '' ,
73+ passwordCheck : '' ,
8374 } ,
8475 onSubmit,
8576 validate : ( { email, password, fullName, passwordCheck } ) => {
8677 const newErrors = { } ;
8778
8879 if ( ! email ) {
8980 newErrors . email = '* 이메일을 입력해 주세요.' ;
90- setEmailInvalid ( true ) ;
9181 } else if ( ! emailValid ( email ) ) {
9282 newErrors . email = '* 이메일 형식이 아닙니다.' ;
93- setEmailInvalid ( true ) ;
94- } else {
95- setEmailInvalid ( false ) ;
9683 }
9784 if ( ! fullName ) {
9885 newErrors . fullName = '* 닉네임을 입력해 주세요.' ;
99- setFullNameInvalid ( true ) ;
100- } else {
101- setFullNameInvalid ( false ) ;
10286 }
10387 if ( ! password || password . length < 8 ) {
10488 newErrors . password = '* 8-10자 사이로 입력해 주세요.' ;
105- setPasswordInvalid ( true ) ;
106- } else {
107- setPasswordInvalid ( false ) ;
10889 }
109- if ( password !== passwordCheck ) {
90+ if ( ! passwordCheck || passwordCheck . length < 8 ) {
91+ newErrors . passwordCheck = '* 8-10자 사이로 입력해 주세요.' ;
92+ } else if ( password !== passwordCheck ) {
11093 newErrors . passwordCheck = '* 비밀번호가 일치하지 않습니다.' ;
111- setPasswordCheckInvalid ( true ) ;
112- } else {
113- setPasswordCheckInvalid ( false ) ;
11494 }
11595
11696 return newErrors ;
@@ -125,36 +105,28 @@ const SignupForm = ({
125105 height = { '70' }
126106 label = { '' }
127107 fontSize = { 18 }
128- inValid = { currentEmailInvalid || errorEmail ? true : false }
108+ inValid = { errorEmail ? true : false }
129109 placeholder = { '이메일을 입력해 주세요.' }
130110 onChange = { handleChange }
131- value = { values . email || '' }
111+ value = { values . email }
132112 onBlur = { handleBlur }
133113 > </ Input >
134- { errorEmail ? (
135- < ErrorText > { errorEmail } </ ErrorText >
136- ) : errors . email ? (
137- < ErrorText > { errors . email } </ ErrorText >
138- ) : (
139- < div style = { { height : '23px' } } > </ div >
140- ) }
114+ { errorEmail ? < ErrorText > { errorEmail } </ ErrorText > : < div style = { { height : '23px' } } > </ div > }
141115 </ InputWrapper >
142116 < InputWrapper >
143117 < Input
144118 name = "fullName"
145119 height = { '70' }
146120 label = { '' }
147121 fontSize = { 18 }
148- inValid = { currentFullNameInvalid || errorfullName ? true : false }
122+ inValid = { errorfullName ? true : false }
149123 placeholder = { '닉네임을 입력해주세요.' }
150124 onBlur = { handleBlur }
151125 onChange = { handleChange }
152- value = { values . fullName || '' }
126+ value = { values . fullName }
153127 > </ Input >
154128 { errorfullName ? (
155129 < ErrorText > { errorfullName } </ ErrorText >
156- ) : errors . fullName ? (
157- < ErrorText > { errors . fullName } </ ErrorText >
158130 ) : (
159131 < ErrorText style = { { color : theme . color . fontNormal } } >
160132 * 특수문자를 제외하고 6자 이내로 입력해 주세요.
@@ -168,16 +140,14 @@ const SignupForm = ({
168140 height = { '70' }
169141 label = { '' }
170142 fontSize = { 18 }
171- inValid = { currentPasswordInvalid || errorPassword ? true : false }
143+ inValid = { errorPassword ? true : false }
172144 placeholder = { '비밀번호를 입력해 주세요.' }
173145 onChange = { handleChange }
174146 value = { values . password }
175147 onBlur = { handleBlur }
176148 > </ Input >
177149 { errorPassword ? (
178150 < ErrorText > { errorPassword } </ ErrorText >
179- ) : errors . password ? (
180- < ErrorText > { errors . password } </ ErrorText >
181151 ) : (
182152 < ErrorText style = { { color : theme . color . fontNormal } } >
183153 * 8-10자 사이로 입력해 주세요.
@@ -191,16 +161,14 @@ const SignupForm = ({
191161 height = { '70' }
192162 label = { '' }
193163 fontSize = { 18 }
194- inValid = { currentPasswordCheckInvalid || errorPasswordCheck ? true : false }
195- placeholder = { '비밀번호를 한번 더 입력해 주세요.' }
164+ inValid = { errorPasswordCheck ? true : false }
165+ placeholder = { '비밀번호를 한 번 더 입력해 주세요.' }
196166 onBlur = { handleBlur }
197167 onChange = { handleChange }
198- value = { values . passwordCheck || '' }
168+ value = { values . passwordCheck }
199169 > </ Input >
200170 { errorPasswordCheck ? (
201171 < ErrorText > { errorPasswordCheck } </ ErrorText >
202- ) : errors . passwordCheck ? (
203- < ErrorText > { errors . passwordCheck } </ ErrorText >
204172 ) : (
205173 < div style = { { height : '23px' } } > </ div >
206174 ) }
0 commit comments