-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLogin.jsx
56 lines (48 loc) ยท 1.67 KB
/
Login.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { Link, useNavigate } from 'react-router-dom';
import LoginForm from './LoginForm';
import { auth, provider } from '../../../firebaseConfig';
import { signInWithPopup } from 'firebase/auth';
import './login.css';
function Login({ isLoggedIn, onChangeIsLoggedIn, onChangeUserId, onChangeDisplayName }) {
const navigate = useNavigate();
async function handleGithubLogin() {
try {
const result = await signInWithPopup(auth, provider);
const user = result.user;
onChangeIsLoggedIn(!isLoggedIn);
onChangeUserId(user.uid);
onChangeDisplayName(user.displayName);
localStorage.setItem('isLoggedIn', true);
localStorage.setItem('userId', user.uid);
localStorage.setItem('displayName', user.displayName);
console.log(user);
navigate('/home');
} catch (error) {
console.log(error);
}
}
return (
<div className='login-page-outer-div scroll-box'>
<div className='login-header'>
<h2>๋ก๊ทธ์ธ</h2>
<div></div>
<button>
<Link to='/'>ํ์ผ๋ก</Link>
</button>
</div>
<img className='project-logo' src='assets/์ผ๋จ๋ฝ.png' alt='๋ฉ์ธ๋ก๊ณ ' />
<LoginForm
isLoggedIn={isLoggedIn}
onChangeIsLoggedIn={onChangeIsLoggedIn}
onChangeUserId={onChangeUserId}
onChangeDisplayName={onChangeDisplayName}
/>
<div className='__or__'> ๋๋ </div>
<div className='github-login-div' onClick={handleGithubLogin}>
<img className='github-img' src='/assets/github-logo.png' alt='๊นํ๋ธ๋ก ๋ก๊ทธ์ธ' />
<span>Github ๊ณ์ ์ผ๋ก ๋ก๊ทธ์ธ</span>
</div>
</div>
);
}
export default Login;