1
1
import * as React from 'react' ;
2
- import styled from 'styled-components' ;
2
+ import styled , { css } from 'styled-components' ;
3
3
import LabelInput from '../common/LabelInput' ;
4
4
import useInputs from '../../lib/hooks/useInputs' ;
5
5
import RoundButton from '../common/RoundButton' ;
6
6
import palette from '../../lib/styles/palette' ;
7
+ import { themedPalette } from '../../lib/styles/themes' ;
8
+ import { CheckIcon } from '../../static/svg' ;
9
+ import { useState , useEffect } from 'react' ;
7
10
8
11
const RegisterFormBlock = styled . div `
9
12
margin-top : 3rem ;
@@ -20,6 +23,41 @@ const RegisterFormBlock = styled.div`
20
23
}
21
24
` ;
22
25
26
+ const CheckRow = styled . div `
27
+ display : flex;
28
+ align-items : center;
29
+ color : ${ themedPalette . text1 } ;
30
+ gap : 0.5rem ;
31
+ cursor : pointer;
32
+
33
+ a {
34
+ color : ${ themedPalette . primary1 } ;
35
+ }
36
+ ` ;
37
+
38
+ const Box = styled . div < { isChecked : boolean } > `
39
+ width: 1.5rem;
40
+ height: 1.5rem;
41
+ border: 1px solid ${ themedPalette . border2 } ;
42
+ border-radius: 4px;
43
+ ${ ( props ) =>
44
+ props . isChecked &&
45
+ css `
46
+ background : ${ themedPalette . primary1 } ;
47
+ border : 1px solid ${ themedPalette . primary1 } ;
48
+ ` }
49
+
50
+ display: flex;
51
+ align-items: center;
52
+ justify-content: center;
53
+
54
+ svg {
55
+ color: white;
56
+ width: 1rem;
57
+ height: 1rem;
58
+ }
59
+ ` ;
60
+
23
61
export type RegisterFormType = {
24
62
displayName : string ;
25
63
email : string ;
@@ -51,6 +89,15 @@ const RegisterForm: React.FC<RegisterFormProps> = ({
51
89
username : defaultInfo ? defaultInfo . username : '' ,
52
90
shortBio : '' ,
53
91
} ) ;
92
+ const [ isChecked , setIsChecked ] = useState ( false ) ;
93
+ const [ localError , setLocalError ] = useState < string | null > ( null ) ;
94
+
95
+ useEffect ( ( ) => {
96
+ if ( isChecked ) {
97
+ setLocalError ( null ) ;
98
+ }
99
+ } , [ isChecked ] ) ;
100
+
54
101
return (
55
102
< RegisterFormBlock >
56
103
< LabelInput
@@ -88,18 +135,53 @@ const RegisterForm: React.FC<RegisterFormProps> = ({
88
135
value = { form . shortBio }
89
136
size = { 30 }
90
137
/>
138
+ < CheckRow
139
+ onClick = { ( ) => {
140
+ setIsChecked ( ( v ) => ! v ) ;
141
+ } }
142
+ >
143
+ < Box isChecked = { isChecked } >
144
+ < CheckIcon />
145
+ </ Box >
146
+ < span >
147
+ < a
148
+ href = "https://velog.io/policy/terms"
149
+ target = "_blank"
150
+ rel = "noopener noreferrer"
151
+ onClick = { ( e ) => e . stopPropagation ( ) }
152
+ >
153
+ 이용약관
154
+ </ a >
155
+ 과{ ' ' }
156
+ < a
157
+ href = "https://velog.io/policy/terms"
158
+ target = "_blank"
159
+ rel = "noopener noreferrer"
160
+ onClick = { ( e ) => e . stopPropagation ( ) }
161
+ >
162
+ 개인정보취급방침
163
+ </ a >
164
+ 에 동의합니다.
165
+ </ span >
166
+ </ CheckRow >
91
167
< div className = "form-bottom" >
92
- { error && < div className = "error" > { error } </ div > }
168
+ { ( error || localError ) && (
169
+ < div className = "error" > { error || localError } </ div >
170
+ ) }
93
171
< div className = "buttons" >
94
172
< RoundButton inline color = "lightGray" to = "/" size = "LARGE" >
95
173
취소
96
174
</ RoundButton >
97
175
< RoundButton
98
176
inline
99
177
type = "submit"
100
- onClick = { ( ) =>
101
- onSubmit ( { ...form , email : fixedEmail || form . email } )
102
- }
178
+ onClick = { ( ) => {
179
+ if ( ! isChecked ) {
180
+ setLocalError ( '이용약관과 개인정보취급방침에 동의해주세요.' ) ;
181
+ return ;
182
+ }
183
+ onSubmit ( { ...form , email : fixedEmail || form . email } ) ;
184
+ } }
103
185
size = "LARGE"
104
186
disabled = { loading }
105
187
>
0 commit comments