From ffbeed38434ece7be28acdf7e3bd900c801a636d Mon Sep 17 00:00:00 2001
From: physcik <mynameisgennadiy@vk.com>
Date: Thu, 7 May 2026 15:44:45 +0500
Subject: Ranged weapons edit page

---
 front/src/Pages/Weapons.tsx | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

(limited to 'front/src/Pages/Weapons.tsx')

diff --git a/front/src/Pages/Weapons.tsx b/front/src/Pages/Weapons.tsx
index 1b72f16..d083ebf 100644
--- a/front/src/Pages/Weapons.tsx
+++ b/front/src/Pages/Weapons.tsx
@@ -5,11 +5,14 @@ import { LanguageContext } from "../Locales/Context";
 import { GetLocalizedString } from "../Locales/Locales";
 import { AllowedLanguages } from "../Locales/Context";
 import { RangedWeapon } from "../Models/RangedWeapon";
+import { AuthContext } from "../Authentication/ContextProvider";
+import { User } from "../Authentication/Models";
 
 const RangedWeaponsURL = `${BackendURL}/weapons/ranged`;
 
 function WeaponsIndex() {
     const lang = useContext(LanguageContext);
+    var user = useContext(AuthContext);
     const [rangedWeapons, setRangedWeapons] = useState<RangedWeapon[] | null>(null);
 
     useState(() => {
@@ -22,7 +25,8 @@ function WeaponsIndex() {
             <h1> {GetLocalizedString("Weapons index", lang)} </h1>
         </span>
             <h2> {GetLocalizedString("Ranged weapons", lang)} </h2>
-            {generatedRangedWeaponsList(rangedWeapons, lang)}
+            { generatedRangedWeaponsList(rangedWeapons, lang) }
+            { adminButtons(user) }
         </div>
     );
 }
@@ -109,4 +113,16 @@ async function getRangedWeapons(): Promise<RangedWeapon[]> {
     }
 }
 
+function adminButtons(user: User | null) {
+    if (!user || user.Role != "editor") {
+        return (<p></p>);
+    } else {
+        return (
+            <div>
+               <a href="/weapons/new/edit"> New ranged weapon </a>
+            </div>
+        )
+    }
+}
+
 export default WeaponsIndex;
-- 
cgit v1.3

