diff options
| author | physcik <mynameisgennadiy@vk.com> | 2026-05-03 21:26:49 +0500 |
|---|---|---|
| committer | physcik <mynameisgennadiy@vk.com> | 2026-05-03 21:26:49 +0500 |
| commit | e02f7ee46876d32ca094c2b5cf3647248baf7645 (patch) | |
| tree | 7f81450d2ccbcb4fea241a0925b45d9385ae7192 /front/src/Emelents/Sidebar.tsx | |
| parent | 533c04d9558bd0a575671c157ca42236f59a2c5a (diff) | |
Register page + logout
Diffstat (limited to 'front/src/Emelents/Sidebar.tsx')
| -rw-r--r-- | front/src/Emelents/Sidebar.tsx | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/front/src/Emelents/Sidebar.tsx b/front/src/Emelents/Sidebar.tsx index ad565fa..34766c3 100644 --- a/front/src/Emelents/Sidebar.tsx +++ b/front/src/Emelents/Sidebar.tsx @@ -1,4 +1,6 @@ import { useContext } from 'react'; +import { AuthContext } from '../Authentication/ContextProvider'; +import { User } from '../Authentication/Models'; import { AllowedLanguages, LanguageContext } from '../Locales/Context'; import { GetLocalizedString } from '../Locales/Locales'; import './Elements.css'; @@ -9,6 +11,7 @@ type SidebarProps = { }; function Sidebar({setLang}: SidebarProps) { + var user = useContext(AuthContext); var lang = useContext(LanguageContext); return ( @@ -19,7 +22,7 @@ function Sidebar({setLang}: SidebarProps) { <SidebarListElement Href='/' Text='Home' /> <SidebarListElement Href='/classes' Text='Classes' /> <SidebarListElement Href='/weapons' Text='Weapons' /> - <SidebarListElement Href='/login' Text='Login' /> + { AuthElement(user) } </ul> <button onClick={() => { setLang("ru"); @@ -34,4 +37,15 @@ function Sidebar({setLang}: SidebarProps) { ); } +function AuthElement(user: User | null) { + if (user != null) { + return ( + <SidebarListElement Href='/logout' Text='Logout' /> + ); + } + return ( + <SidebarListElement Href='/login' Text='Login' /> + ); +} + export default Sidebar; |
