@@ -6,9 +6,12 @@ import { useRouter } from "next/navigation";
66
77export default function AuthPage ( ) {
88 const [ error , setError ] = useState < string | null > ( null ) ;
9+ const [ loading , setLoading ] = useState ( false ) ;
910 const router = useRouter ( ) ;
1011
1112 const handleLoginWithGoogle = async ( ) => {
13+ setLoading ( true ) ;
14+ setError ( null ) ;
1215 try {
1316 const result = await signInWithGoogle ( ) ;
1417 if ( result ?. isAdmin ) {
@@ -19,6 +22,8 @@ export default function AuthPage() {
1922 } catch ( err ) {
2023 console . error ( "Failed to log in with Google:" , err ) ;
2124 setError ( err instanceof Error ? err . message : "Failed to log in with Google" ) ;
25+ } finally {
26+ setLoading ( false ) ;
2227 }
2328 } ;
2429
@@ -31,18 +36,28 @@ export default function AuthPage() {
3136
3237 < button
3338 onClick = { handleLoginWithGoogle }
39+ disabled = { loading }
3440 aria-label = "Login with Google"
3541 type = "button"
3642 className = "flex items-center justify-center w-full p-3 space-x-3 border rounded-lg
3743 bg-gray-100 hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700
38- dark:border-gray-700 focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all"
44+ dark:border-gray-700 focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all
45+ disabled:opacity-50 disabled:cursor-not-allowed"
3946 >
40- < svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 32 32" className = "w-6 h-6 fill-current text-gray-700 dark:text-gray-200" >
41- < path d = "M16.318 13.714v5.484h9.078c-0.37 2.354-2.745 6.901-9.078 6.901-5.458 0-9.917-4.521-9.917-10.099s4.458-10.099 9.917-10.099c3.109 0 5.193 1.318 6.38 2.464l4.339-4.182c-2.786-2.599-6.396-4.182-10.719-4.182-8.844 0-16 7.151-16 16s7.156 16 16 16c9.234 0 15.365-6.49 15.365-15.635 0-1.052-0.115-1.854-0.255-2.651z" > </ path >
42- </ svg >
43- < span className = "text-lg font-medium text-gray-900 dark:text-gray-200" >
44- Login with Google
45- </ span >
47+ { loading ? (
48+ < span className = "text-lg font-medium text-gray-900 dark:text-gray-200" >
49+ Logging in...
50+ </ span >
51+ ) : (
52+ < >
53+ < svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 32 32" className = "w-6 h-6 fill-current text-gray-700 dark:text-gray-200" >
54+ < path d = "M16.318 13.714v5.484h9.078c-0.37 2.354-2.745 6.901-9.078 6.901-5.458 0-9.917-4.521-9.917-10.099s4.458-10.099 9.917-10.099c3.109 0 5.193 1.318 6.38 2.464l4.339-4.182c-2.786-2.599-6.396-4.182-10.719-4.182-8.844 0-16 7.151-16 16s7.156 16 16 16c9.234 0 15.365-6.49 15.365-15.635 0-1.052-0.115-1.854-0.255-2.651z" > </ path >
55+ </ svg >
56+ < span className = "text-lg font-medium text-gray-900 dark:text-gray-200" >
57+ Login with Google
58+ </ span >
59+ </ >
60+ ) }
4661 </ button >
4762
4863 { error && < p className = "text-red-500 text-sm text-center" > { error } </ p > }
0 commit comments