diff options
| author | FifthWit <fifthwitbusiness@gmail.com> | 2025-01-30 10:44:30 -0600 |
|---|---|---|
| committer | FifthWit <fifthwitbusiness@gmail.com> | 2025-01-30 10:44:30 -0600 |
| commit | e40f07211f5f15dcb138e2520a76d13afd3c0cfd (patch) | |
| tree | 46bad6a17e66d55a4a65088c0b6eb8c48641615a /frontend/src/components/Login.tsx | |
| parent | added prettier for more consistency (diff) | |
| download | lphub-e40f07211f5f15dcb138e2520a76d13afd3c0cfd.tar.gz lphub-e40f07211f5f15dcb138e2520a76d13afd3c0cfd.tar.bz2 lphub-e40f07211f5f15dcb138e2520a76d13afd3c0cfd.zip | |
formatted with prettier
Diffstat (limited to 'frontend/src/components/Login.tsx')
| -rw-r--r-- | frontend/src/components/Login.tsx | 103 |
1 files changed, 52 insertions, 51 deletions
diff --git a/frontend/src/components/Login.tsx b/frontend/src/components/Login.tsx index f1628b2..093e406 100644 --- a/frontend/src/components/Login.tsx +++ b/frontend/src/components/Login.tsx | |||
| @@ -4,77 +4,78 @@ import { Link, useNavigate } from 'react-router-dom'; | |||
| 4 | import { ExitIcon, UserIcon, LoginIcon } from '@images/Images'; | 4 | import { ExitIcon, UserIcon, LoginIcon } from '@images/Images'; |
| 5 | import { UserProfile } from '@customTypes/Profile'; | 5 | import { UserProfile } from '@customTypes/Profile'; |
| 6 | import { API } from '@api/Api'; | 6 | import { API } from '@api/Api'; |
| 7 | import "@css/Login.css"; | 7 | import '@css/Login.css'; |
| 8 | 8 | ||
| 9 | interface LoginProps { | 9 | interface LoginProps { |
| 10 | setToken: React.Dispatch<React.SetStateAction<string | undefined>>; | 10 | setToken: React.Dispatch<React.SetStateAction<string | undefined>>; |
| 11 | profile?: UserProfile; | 11 | profile?: UserProfile; |
| 12 | setProfile: React.Dispatch<React.SetStateAction<UserProfile | undefined>>; | 12 | setProfile: React.Dispatch<React.SetStateAction<UserProfile | undefined>>; |
| 13 | }; | 13 | } |
| 14 | 14 | ||
| 15 | const Login: React.FC<LoginProps> = ({ setToken, profile, setProfile }) => { | 15 | const Login: React.FC<LoginProps> = ({ setToken, profile, setProfile }) => { |
| 16 | |||
| 17 | const navigate = useNavigate(); | 16 | const navigate = useNavigate(); |
| 18 | 17 | ||
| 19 | const _login = () => { | 18 | const _login = () => { |
| 20 | window.location.href = "/api/v1/login"; | 19 | window.location.href = '/api/v1/login'; |
| 21 | }; | 20 | }; |
| 22 | 21 | ||
| 23 | const _logout = () => { | 22 | const _logout = () => { |
| 24 | setProfile(undefined); | 23 | setProfile(undefined); |
| 25 | setToken(undefined); | 24 | setToken(undefined); |
| 26 | API.delete_token(); | 25 | API.delete_token(); |
| 27 | navigate("/"); | 26 | navigate('/'); |
| 28 | }; | 27 | }; |
| 29 | 28 | ||
| 30 | return ( | 29 | return ( |
| 31 | <> | 30 | <> |
| 32 | {profile | 31 | {profile ? ( |
| 33 | ? | 32 | <> |
| 34 | ( | 33 | {profile.profile ? ( |
| 35 | <> | 34 | <> |
| 36 | {profile.profile ? | 35 | <Link to="/profile" tabIndex={-1} className="login"> |
| 37 | ( | 36 | <button className="sidebar-button"> |
| 38 | <> | 37 | <img |
| 39 | <Link to="/profile" tabIndex={-1} className='login'> | 38 | className="avatar-img" |
| 40 | <button className='sidebar-button'> | 39 | src={profile.avatar_link} |
| 41 | <img className="avatar-img" src={profile.avatar_link} alt="" /> | 40 | alt="" |
| 42 | <span>{profile.user_name}</span> | 41 | /> |
| 43 | </button> | 42 | <span>{profile.user_name}</span> |
| 44 | <button className='logout-button' onClick={_logout}> | 43 | </button> |
| 45 | <img src={ExitIcon} alt="" /><span /> | 44 | <button className="logout-button" onClick={_logout}> |
| 46 | </button> | 45 | <img src={ExitIcon} alt="" /> |
| 47 | </Link> | 46 | <span /> |
| 48 | </> | 47 | </button> |
| 49 | ) | 48 | </Link> |
| 50 | : | 49 | </> |
| 51 | ( | 50 | ) : ( |
| 52 | <> | 51 | <> |
| 53 | <Link to="/" tabIndex={-1} className='login'> | 52 | <Link to="/" tabIndex={-1} className="login"> |
| 54 | <button className='sidebar-button'> | 53 | <button className="sidebar-button"> |
| 55 | <img className="avatar-img" src={profile.avatar_link} alt="" /> | 54 | <img |
| 56 | <span>Loading Profile...</span> | 55 | className="avatar-img" |
| 57 | </button> | 56 | src={profile.avatar_link} |
| 58 | <button disabled className='logout-button' onClick={_logout}> | 57 | alt="" |
| 59 | <img src={ExitIcon} alt="" /><span /> | 58 | /> |
| 60 | </button> | 59 | <span>Loading Profile...</span> |
| 61 | </Link> | 60 | </button> |
| 62 | </> | 61 | <button disabled className="logout-button" onClick={_logout}> |
| 63 | ) | 62 | <img src={ExitIcon} alt="" /> |
| 64 | } | 63 | <span /> |
| 65 | </> | 64 | </button> |
| 66 | ) | 65 | </Link> |
| 67 | : | 66 | </> |
| 68 | ( | 67 | )} |
| 69 | <Link to="/api/v1/login" tabIndex={-1} className='login' > | 68 | </> |
| 70 | <button className='sidebar-button' onClick={_login}> | 69 | ) : ( |
| 71 | <img className="avatar-img" src={UserIcon} alt="" /> | 70 | <Link to="/api/v1/login" tabIndex={-1} className="login"> |
| 72 | <span> | 71 | <button className="sidebar-button" onClick={_login}> |
| 73 | <img src={LoginIcon} alt="Sign in through Steam" /> | 72 | <img className="avatar-img" src={UserIcon} alt="" /> |
| 74 | </span> | 73 | <span> |
| 75 | </button> | 74 | <img src={LoginIcon} alt="Sign in through Steam" /> |
| 76 | </Link> | 75 | </span> |
| 77 | )} | 76 | </button> |
| 77 | </Link> | ||
| 78 | )} | ||
| 78 | </> | 79 | </> |
| 79 | ); | 80 | ); |
| 80 | }; | 81 | }; |