11import { useState } from 'react' ;
22import { useAuth } from '../contexts/AuthContext' ;
3- import { Keyboard , Mail , Lock , AlertCircle } from 'lucide-react' ;
3+ import { Keyboard , Mail , Lock , AlertCircle , Github } from 'lucide-react' ;
44
55export default function Auth ( ) {
66 const [ isLogin , setIsLogin ] = useState ( true ) ;
77 const [ email , setEmail ] = useState ( '' ) ;
88 const [ password , setPassword ] = useState ( '' ) ;
99 const [ error , setError ] = useState ( '' ) ;
1010 const [ loading , setLoading ] = useState ( false ) ;
11- const { signIn, signUp } = useAuth ( ) ;
11+ const { signIn, signUp, signInWithGithub } = useAuth ( ) ;
1212
1313 const handleSubmit = async ( e : React . FormEvent ) => {
1414 e . preventDefault ( ) ;
@@ -26,6 +26,16 @@ export default function Auth() {
2626 setLoading ( false ) ;
2727 } ;
2828
29+ const handleGithubSignIn = async ( ) => {
30+ setError ( '' ) ;
31+ setLoading ( true ) ;
32+ const { error } = await signInWithGithub ( ) ;
33+ if ( error ) {
34+ setError ( error . message ) ;
35+ }
36+ setLoading ( false ) ;
37+ } ;
38+
2939 return (
3040 < div className = "min-h-screen bg-gradient-to-br from-blue-50 to-green-50 flex items-center justify-center px-4" >
3141 < div className = "max-w-md w-full" >
@@ -68,6 +78,27 @@ export default function Auth() {
6878 </ div >
6979 ) }
7080
81+ { /* GitHub Sign-In Button */ }
82+ < button
83+ onClick = { handleGithubSignIn }
84+ disabled = { loading }
85+ className = "w-full py-3 mb-4 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition-colors font-medium disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2"
86+ >
87+ < Github className = "w-5 h-5" />
88+ Sign in with GitHub
89+ </ button >
90+
91+ < div className = "relative mb-4" >
92+ < div className = "absolute inset-0 flex items-center" >
93+ < div className = "w-full border-t border-gray-300" > </ div >
94+ </ div >
95+ < div className = "relative flex justify-center text-sm" >
96+ < span className = "px-2 bg-white text-gray-500" >
97+ Or continue with email
98+ </ span >
99+ </ div >
100+ </ div >
101+
71102 < form onSubmit = { handleSubmit } className = "space-y-4" >
72103 < div >
73104 < label className = "block text-sm font-medium text-gray-700 mb-2" >
0 commit comments