diff options
Diffstat (limited to 'front/src/Emelents')
| -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; |
