Download src/components/Login.js from UnDaoDu/aimindmap: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/spaces/UnDaoDu/aimindmap/resolve/main/src/components/Login.js
- Command line
-
hf download hf://spaces/UnDaoDu/aimindmap/src/components/Login.js
-
curl -L -o Login.js https://huggingface.co/spaces/UnDaoDu/aimindmap/resolve/main/src/components/Login.js
1.63 kB
| import React from 'react'; | |
| import { authService } from '../services/auth_service'; | |
| import { useAuthState } from 'react-firebase-hooks/auth'; | |
| import { auth } from '../services/firebase'; | |
| export function Login() { | |
| const [user, loading, error] = useAuthState(auth); | |
| const handleGoogleSignIn = async () => { | |
| try { | |
| await authService.signInWithGoogle(); | |
| } catch (error) { | |
| console.error('Login failed:', error); | |
| } | |
| }; | |
| const handleSignOut = async () => { | |
| try { | |
| await authService.signOut(); | |
| } catch (error) { | |
| console.error('Logout failed:', error); | |
| } | |
| }; | |
| if (loading) { | |
| return ( | |
| <div className="login-container"> | |
| <p>Loading...</p> | |
| </div> | |
| ); | |
| } | |
| if (error) { | |
| return ( | |
| <div className="login-container"> | |
| <p>Error: {error.message}</p> | |
| </div> | |
| ); | |
| } | |
| return ( | |
| <div className="login-container"> | |
| {user ? ( | |
| <div className="user-info"> | |
| <img | |
| src={user.photoURL} | |
| alt={user.displayName} | |
| className="user-avatar" | |
| /> | |
| <div className="user-details"> | |
| <p className="user-name">{user.displayName}</p> | |
| <p className="user-email">{user.email}</p> | |
| <button | |
| onClick={handleSignOut} | |
| className="sign-out-btn" | |
| > | |
| Sign Out | |
| </button> | |
| </div> | |
| </div> | |
| ) : ( | |
| <button | |
| onClick={handleGoogleSignIn} | |
| className="google-sign-in-btn" | |
| > | |
| Sign in with Google | |
| </button> | |
| )} | |
| </div> | |
| ); | |
| } |