From e02f7ee46876d32ca094c2b5cf3647248baf7645 Mon Sep 17 00:00:00 2001
From: physcik <mynameisgennadiy@vk.com>
Date: Sun, 3 May 2026 21:26:49 +0500
Subject: Register page + logout

---
 front/src/Emelents/Sidebar.tsx | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

(limited to 'front/src/Emelents/Sidebar.tsx')

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;
-- 
cgit v1.3

