From 681f7d3ba097cd8d204ff3ac4dae01432d323e5b Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Thu, 30 Jan 2025 14:43:17 +0300 Subject: feat/frontend: dynamic title and meta descriptions (#261) --- frontend/src/pages/Maplist.tsx | 48 +++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'frontend/src/pages/Maplist.tsx') diff --git a/frontend/src/pages/Maplist.tsx b/frontend/src/pages/Maplist.tsx index 8fc52b0..04938cf 100644 --- a/frontend/src/pages/Maplist.tsx +++ b/frontend/src/pages/Maplist.tsx @@ -1,5 +1,6 @@ import React, { useEffect } from "react"; import { Link, useLocation, useNavigate, useParams } from "react-router-dom"; +import { Helmet } from "react-helmet"; import "@css/Maplist.css"; import { API } from "@api/Api"; @@ -25,9 +26,9 @@ const Maplist: React.FC = () => { const navigate = useNavigate(); function _update_currently_selected(catNum2: number) { - setCurrentlySelected(catNum2); - navigate("/games/" + game?.id + "?cat=" + catNum2); - setHasClicked(true); + setCurrentlySelected(catNum2); + navigate("/games/" + game?.id + "?cat=" + catNum2); + setHasClicked(true); } const _fetch_chapters = async (chapter_id: string) => { @@ -52,12 +53,12 @@ const Maplist: React.FC = () => { // location query params const queryParams = new URLSearchParams(location.search); if (queryParams.get("chapter")) { - let cat = parseFloat(queryParams.get("chapter") || ""); - if (gameId == 2) { - cat += 10; - } - _fetch_chapters(cat.toString()); - } + let cat = parseFloat(queryParams.get("chapter") || ""); + if (gameId == 2) { + cat += 10; + } + _fetch_chapters(cat.toString()); + } const _fetch_game = async () => { const games = await API.get_games(); @@ -68,7 +69,7 @@ const Maplist: React.FC = () => { setLoad(false); } }; - + const _fetch_game_chapters = async () => { const games_chapters = await API.get_games_chapters(gameId.toString()); setGameChapters(games_chapters); @@ -81,7 +82,7 @@ const Maplist: React.FC = () => { }, []); useEffect(() => { - const queryParams = new URLSearchParams(location.search); + const queryParams = new URLSearchParams(location.search); if (gameChapters != undefined && !queryParams.get("chapter")) { _fetch_chapters(gameChapters!.chapters[0].id.toString()); } @@ -91,6 +92,9 @@ const Maplist: React.FC = () => { return (
+ + LPHUB | Maplist +
))} @@ -132,26 +136,26 @@ const Maplist: React.FC = () => {
- {curChapter?.chapter.name.split(" - ")[0]} + {curChapter?.chapter.name.split(" - ")[0]}
{curChapter?.chapter.name.split(" - ")[1]}
-
+
{gameChapters?.chapters.map((chapter, i) => { - return
{_fetch_chapters(chapter.id.toString()); _handle_dropdown_click()}}>{chapter.name}
+ return
{ _fetch_chapters(chapter.id.toString()); _handle_dropdown_click() }}>{chapter.name}
}) }
- {curChapter?.maps.map((map, i) => { - return
- + {curChapter?.maps.map((map, i) => { + return
+ {map.name} -
+
{map.is_disabled ? map.category_portals[0].portal_count : map.category_portals.find( (obj) => obj.category.id === catNum + 1 @@ -169,9 +173,9 @@ const Maplist: React.FC = () => {
- -
- })} + +
+ })}
-- cgit v1.2.3