@@ -131,6 +131,30 @@ function SignUpForm() {
131131 }
132132 } ;
133133
134+ const handleGitHubSignIn = async ( ) => {
135+ setIsLoading ( true ) ;
136+ try {
137+ const supabase = createClient ( ) ;
138+ const { error } = await supabase . auth . signInWithOAuth ( {
139+ provider : 'github' ,
140+ options : {
141+ redirectTo : typeof window !== "undefined"
142+ ? `${ window . location . origin } /auth/callback?returnUrl=${ encodeURIComponent ( returnUrl ) } `
143+ : undefined ,
144+ } ,
145+ } ) ;
146+ if ( error ) {
147+ throw error ;
148+ }
149+ toast . success ( "Redirecting to GitHub..." ) ;
150+ } catch ( error ) {
151+ console . error ( 'GitHub sign in error:' , error ) ;
152+ toast . error ( "GitHub sign in failed. Please try again." ) ;
153+ } finally {
154+ setIsLoading ( false ) ;
155+ }
156+ } ;
157+
134158 const passwordRequirements = [
135159 { text : "At least 8 characters" , met : formData . password . length >= 8 } ,
136160 { text : "Contains uppercase letter" , met : / [ A - Z ] / . test ( formData . password ) } ,
@@ -337,9 +361,23 @@ function SignUpForm() {
337361 < CardContent className = "space-y-6 relative" >
338362 { /* socials login */ }
339363 < div className = "grid grid-cols-2 gap-4" >
340- < Button variant = "outline" className = "w-full hover:bg-background/80 transition-colors backdrop-blur-sm border-white/10 hover:border-primary/20" >
341- < Github className = "mr-2 h-4 w-4" />
342- GitHub
364+ < Button
365+ variant = "outline"
366+ className = "w-full hover:bg-background/80 transition-colors backdrop-blur-sm border-white/10 hover:border-primary/20"
367+ onClick = { handleGitHubSignIn }
368+ disabled = { isLoading }
369+ >
370+ { isLoading ? (
371+ < div className = "flex items-center" >
372+ < div className = "animate-spin rounded-full h-4 w-4 border-2 border-primary border-t-transparent mr-2" > </ div >
373+ Connecting...
374+ </ div >
375+ ) : (
376+ < >
377+ < Github className = "mr-2 h-4 w-4" />
378+ GitHub
379+ </ >
380+ ) }
343381 </ Button >
344382 < Button
345383 variant = "outline"
0 commit comments