From bbd8f8970901bb0bcadb8703f74db0f781627ea0 Mon Sep 17 00:00:00 2001
From: Wolfboy248 <georgejvindkarlsen@gmail.com>
Date: Wed, 30 Oct 2024 09:33:33 +0100
Subject: frontend: maplist chapter param fix

---
 frontend/src/pages/Maplist.tsx | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

(limited to 'frontend/src/pages/Maplist.tsx')

diff --git a/frontend/src/pages/Maplist.tsx b/frontend/src/pages/Maplist.tsx
index 9526d18..31b7b2e 100644
--- a/frontend/src/pages/Maplist.tsx
+++ b/frontend/src/pages/Maplist.tsx
@@ -21,7 +21,7 @@ const Maplist: React.FC = () => {
 
   const [dropdownActive, setDropdownActive] = React.useState("none");
 
-  const params = useParams<{ id: string }>();
+  const params = useParams<{ id: string, chapter: string }>();
   const location = useLocation();
   const navigate = useNavigate();
 
@@ -52,11 +52,10 @@ const Maplist: React.FC = () => {
 
     // location query params
     const queryParams = new URLSearchParams(location.search);
-    if (queryParams.get("cat")) {
-        const cat = parseFloat(queryParams.get("cat") || "");
-        setCategory(cat);
-        setCatNum(cat - 1);
-    }
+    if (queryParams.get("chapter")) {
+        const cat = parseFloat(queryParams.get("chapter") || "");
+		_fetch_chapters(cat.toString());
+	}
 
     const _fetch_game = async () => {
       const games = await API.get_games();
@@ -80,7 +79,8 @@ const Maplist: React.FC = () => {
   }, []);
 
   useEffect(() => {
-    if (gameChapters != undefined) {
+  	const queryParams = new URLSearchParams(location.search);
+    if (gameChapters != undefined && queryParams.get("chapter") == "") {
       _fetch_chapters(gameChapters!.chapters[0].id.toString());
     }
   }, [gameChapters])
-- 
cgit v1.2.3

