diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2025-07-24 14:40:22 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2025-07-24 14:40:22 +0300 |
| commit | b0d199936b546c75d4b19d99591237f0bf97fe55 (patch) | |
| tree | e9391880e7db2bd1ea8ff25d91aeea8dd98f186e /frontend/src/pages/Maplist.tsx | |
| parent | fix/frontend: fixed sidebar title size, removed unnecessary imports (diff) | |
| parent | feat/backend: add newrelic integration (#274) (diff) | |
| download | lphub-css-overhaul.tar.gz lphub-css-overhaul.tar.bz2 lphub-css-overhaul.zip | |
Merge branch 'main' into css-overhaulcss-overhaul
Diffstat (limited to 'frontend/src/pages/Maplist.tsx')
| -rw-r--r-- | frontend/src/pages/Maplist.tsx | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/frontend/src/pages/Maplist.tsx b/frontend/src/pages/Maplist.tsx index ecea3e1..b9e17f7 100644 --- a/frontend/src/pages/Maplist.tsx +++ b/frontend/src/pages/Maplist.tsx | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | import React, { useEffect } from "react"; | 1 | import React, { useEffect } from "react"; |
| 2 | import { Link, useLocation, useNavigate, useParams } from "react-router-dom"; | 2 | import { Link, useLocation, useNavigate, useParams } from "react-router-dom"; |
| 3 | import { Helmet } from "react-helmet"; | ||
| 3 | 4 | ||
| 4 | import "@css/Maplist.css"; | 5 | import "@css/Maplist.css"; |
| 5 | import { API } from "@api/Api"; | 6 | import { API } from "@api/Api"; |
| @@ -25,9 +26,9 @@ const Maplist: React.FC = () => { | |||
| 25 | const navigate = useNavigate(); | 26 | const navigate = useNavigate(); |
| 26 | 27 | ||
| 27 | function _update_currently_selected(catNum2: number) { | 28 | function _update_currently_selected(catNum2: number) { |
| 28 | setCurrentlySelected(catNum2); | 29 | setCurrentlySelected(catNum2); |
| 29 | navigate("/games/" + game?.id + "?cat=" + catNum2); | 30 | navigate("/games/" + game?.id + "?cat=" + catNum2); |
| 30 | setHasClicked(true); | 31 | setHasClicked(true); |
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | const _fetch_chapters = async (chapter_id: string) => { | 34 | const _fetch_chapters = async (chapter_id: string) => { |
| @@ -52,12 +53,12 @@ const Maplist: React.FC = () => { | |||
| 52 | // location query params | 53 | // location query params |
| 53 | const queryParams = new URLSearchParams(location.search); | 54 | const queryParams = new URLSearchParams(location.search); |
| 54 | if (queryParams.get("chapter")) { | 55 | if (queryParams.get("chapter")) { |
| 55 | let cat = parseFloat(queryParams.get("chapter") || ""); | 56 | let cat = parseFloat(queryParams.get("chapter") || ""); |
| 56 | if (gameId == 2) { | 57 | if (gameId == 2) { |
| 57 | cat += 10; | 58 | cat += 10; |
| 58 | } | 59 | } |
| 59 | _fetch_chapters(cat.toString()); | 60 | _fetch_chapters(cat.toString()); |
| 60 | } | 61 | } |
| 61 | 62 | ||
| 62 | const _fetch_game = async () => { | 63 | const _fetch_game = async () => { |
| 63 | const games = await API.get_games(); | 64 | const games = await API.get_games(); |
| @@ -68,7 +69,7 @@ const Maplist: React.FC = () => { | |||
| 68 | setLoad(false); | 69 | setLoad(false); |
| 69 | } | 70 | } |
| 70 | }; | 71 | }; |
| 71 | 72 | ||
| 72 | const _fetch_game_chapters = async () => { | 73 | const _fetch_game_chapters = async () => { |
| 73 | const games_chapters = await API.get_games_chapters(gameId.toString()); | 74 | const games_chapters = await API.get_games_chapters(gameId.toString()); |
| 74 | setGameChapters(games_chapters); | 75 | setGameChapters(games_chapters); |
| @@ -81,7 +82,7 @@ const Maplist: React.FC = () => { | |||
| 81 | }, []); | 82 | }, []); |
| 82 | 83 | ||
| 83 | useEffect(() => { | 84 | useEffect(() => { |
| 84 | const queryParams = new URLSearchParams(location.search); | 85 | const queryParams = new URLSearchParams(location.search); |
| 85 | if (gameChapters != undefined && !queryParams.get("chapter")) { | 86 | if (gameChapters != undefined && !queryParams.get("chapter")) { |
| 86 | _fetch_chapters(gameChapters!.chapters[0].id.toString()); | 87 | _fetch_chapters(gameChapters!.chapters[0].id.toString()); |
| 87 | } | 88 | } |
| @@ -97,6 +98,9 @@ const Maplist: React.FC = () => { | |||
| 97 | 98 | ||
| 98 | return ( | 99 | return ( |
| 99 | <main> | 100 | <main> |
| 101 | <Helmet> | ||
| 102 | <title>LPHUB | Maplist</title> | ||
| 103 | </Helmet> | ||
| 100 | <section style={{ marginTop: "20px" }}> | 104 | <section style={{ marginTop: "20px" }}> |
| 101 | <Link to="/games"> | 105 | <Link to="/games"> |
| 102 | <button className="nav-button" style={{ borderRadius: "20px" }}> | 106 | <button className="nav-button" style={{ borderRadius: "20px" }}> |
| @@ -129,7 +133,7 @@ const Maplist: React.FC = () => { | |||
| 129 | </div> | 133 | </div> |
| 130 | <div className="game-header-categories"> | 134 | <div className="game-header-categories"> |
| 131 | {game?.category_portals.map((cat, index) => ( | 135 | {game?.category_portals.map((cat, index) => ( |
| 132 | <button key={index} className={currentlySelected == cat.category.id || cat.category.id - 1 == catNum && !hasClicked ? "game-cat-button selected" : "game-cat-button"} onClick={() => {setCatNum(cat.category.id - 1); _update_currently_selected(cat.category.id)}}> | 136 | <button key={index} className={currentlySelected == cat.category.id || cat.category.id - 1 == catNum && !hasClicked ? "game-cat-button selected" : "game-cat-button"} onClick={() => { setCatNum(cat.category.id - 1); _update_currently_selected(cat.category.id) }}> |
| 133 | <span>{cat.category.name}</span> | 137 | <span>{cat.category.name}</span> |
| 134 | </button> | 138 | </button> |
| 135 | ))} | 139 | ))} |
| @@ -140,26 +144,26 @@ const Maplist: React.FC = () => { | |||
| 140 | <div> | 144 | <div> |
| 141 | <section className="chapter-select-container"> | 145 | <section className="chapter-select-container"> |
| 142 | <div> | 146 | <div> |
| 143 | <span style={{fontSize: "18px", transform: "translateY(5px)", display: "block", marginTop: "10px"}}>{curChapter?.chapter.name.split(" - ")[0]}</span> | 147 | <span style={{ fontSize: "18px", transform: "translateY(5px)", display: "block", marginTop: "10px" }}>{curChapter?.chapter.name.split(" - ")[0]}</span> |
| 144 | </div> | 148 | </div> |
| 145 | <div onClick={_handle_dropdown_click} className="dropdown"> | 149 | <div onClick={_handle_dropdown_click} className="dropdown"> |
| 146 | <span>{curChapter?.chapter.name.split(" - ")[1]}</span> | 150 | <span>{curChapter?.chapter.name.split(" - ")[1]}</span> |
| 147 | <i className="triangle"></i> | 151 | <i className="triangle"></i> |
| 148 | </div> | 152 | </div> |
| 149 | <div className="dropdown-elements" style={{display: dropdownActive}}> | 153 | <div className="dropdown-elements" style={{ display: dropdownActive }}> |
| 150 | {gameChapters?.chapters.map((chapter, i) => { | 154 | {gameChapters?.chapters.map((chapter, i) => { |
| 151 | return <div className="dropdown-element" onClick={() => {_fetch_chapters(chapter.id.toString()); _handle_dropdown_click()}}>{chapter.name}</div> | 155 | return <div className="dropdown-element" onClick={() => { _fetch_chapters(chapter.id.toString()); _handle_dropdown_click() }}>{chapter.name}</div> |
| 152 | }) | 156 | }) |
| 153 | 157 | ||
| 154 | } | 158 | } |
| 155 | </div> | 159 | </div> |
| 156 | </section> | 160 | </section> |
| 157 | <section className="maplist"> | 161 | <section className="maplist"> |
| 158 | {curChapter?.maps.map((map, i) => { | 162 | {curChapter?.maps.map((map, i) => { |
| 159 | return <div className="maplist-entry"> | 163 | return <div className="maplist-entry"> |
| 160 | <Link to={`/maps/${map.id}`}> | 164 | <Link to={`/maps/${map.id}`}> |
| 161 | <span>{map.name}</span> | 165 | <span>{map.name}</span> |
| 162 | <div className="map-entry-image" style={{backgroundImage: `url(${map.image})`}}> | 166 | <div className="map-entry-image" style={{ backgroundImage: `url(${map.image})` }}> |
| 163 | <div className="blur map"> | 167 | <div className="blur map"> |
| 164 | <span>{map.is_disabled ? map.category_portals[0].portal_count : map.category_portals.find( | 168 | <span>{map.is_disabled ? map.category_portals[0].portal_count : map.category_portals.find( |
| 165 | (obj) => obj.category.id === catNum + 1 | 169 | (obj) => obj.category.id === catNum + 1 |
| @@ -169,7 +173,7 @@ const Maplist: React.FC = () => { | |||
| 169 | </div> | 173 | </div> |
| 170 | <div className="difficulty-bar"> | 174 | <div className="difficulty-bar"> |
| 171 | {/* <span>Difficulty:</span> */} | 175 | {/* <span>Difficulty:</span> */} |
| 172 | <div className={map.difficulty == 0 ? "one" : map.difficulty == 1 ? "two" : map.difficulty == 2 ? "three" : map.difficulty == 3 ? "four" : map.difficulty == 4 ? "five" : "one"}> | 176 | <div className={map.difficulty <= 2 ? "one" : map.difficulty <= 4 ? "two" : map.difficulty <= 6 ? "three" : map.difficulty <= 8 ? "four" : map.difficulty <= 10 ? "five" : "one"}> |
| 173 | <div className="difficulty-point"></div> | 177 | <div className="difficulty-point"></div> |
| 174 | <div className="difficulty-point"></div> | 178 | <div className="difficulty-point"></div> |
| 175 | <div className="difficulty-point"></div> | 179 | <div className="difficulty-point"></div> |
| @@ -177,9 +181,9 @@ const Maplist: React.FC = () => { | |||
| 177 | <div className="difficulty-point"></div> | 181 | <div className="difficulty-point"></div> |
| 178 | </div> | 182 | </div> |
| 179 | </div> | 183 | </div> |
| 180 | </Link> | 184 | </Link> |
| 181 | </div> | 185 | </div> |
| 182 | })} | 186 | })} |
| 183 | </section> | 187 | </section> |
| 184 | </div> | 188 | </div> |
| 185 | </section> | 189 | </section> |