@@ -11,6 +11,7 @@ export default function LoginButton() {
11
11
const [ pullRequests , setPullRequests ] = useState ( [ ] ) ;
12
12
const [ isLoading , setIsLoading ] = useState ( false ) ;
13
13
const [ isSigningIn , setIsSigningIn ] = useState ( false ) ;
14
+ const [ isConsentGiven , setConsentGiven ] = useState ( false ) ; // Consent state
14
15
15
16
useEffect ( ( ) => {
16
17
if ( session ?. user ?. email ) {
@@ -28,7 +29,16 @@ export default function LoginButton() {
28
29
}
29
30
} , [ session ] ) ;
30
31
32
+ const handleConsentChange = ( ) => {
33
+ setConsentGiven ( ! isConsentGiven ) ;
34
+ } ;
35
+
31
36
const handleSignIn = async ( ) => {
37
+ if ( ! isConsentGiven ) {
38
+ alert ( "You must agree to the Privacy Policy to proceed." ) ;
39
+ return ;
40
+ }
41
+
32
42
setIsSigningIn ( true ) ;
33
43
try {
34
44
await signIn ( "github" ) ;
@@ -39,7 +49,6 @@ export default function LoginButton() {
39
49
}
40
50
} ;
41
51
42
-
43
52
const size = 200 ;
44
53
45
54
if ( session ?. user ) {
@@ -130,9 +139,28 @@ export default function LoginButton() {
130
139
Sign in with GitHub
131
140
</ h2 >
132
141
</ div >
142
+ < div className = "consent-checkbox" >
143
+ < input
144
+ type = "checkbox"
145
+ id = "consentCheckbox"
146
+ checked = { isConsentGiven }
147
+ onChange = { handleConsentChange }
148
+ />
149
+ < label htmlFor = "consentCheckbox" className = "pl-2" >
150
+ I agree to the{ " " }
151
+ < a
152
+ href = "/privacy-policy"
153
+ target = "_blank"
154
+ rel = "noopener noreferrer"
155
+ className = "text-blue-400 hover:underline"
156
+ >
157
+ Privacy Policy
158
+ </ a >
159
+ </ label >
160
+ </ div >
133
161
< button
134
162
onClick = { handleSignIn }
135
- className = "py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-gray-800 hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 inline-flex items-center space-x-2"
163
+ className = "py-2 px-4 my-4 border border-transparent text-sm font-medium rounded-md text-white bg-gray-800 hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 inline-flex items-center space-x-2"
136
164
>
137
165
{ isSigningIn ? (
138
166
< div className = "spinner" > </ div >
0 commit comments