diff options
| author | Wolfboy248 <georgejvindkarlsen@gmail.com> | 2024-10-30 09:33:33 +0100 |
|---|---|---|
| committer | Wolfboy248 <georgejvindkarlsen@gmail.com> | 2024-10-30 09:33:33 +0100 |
| commit | bbd8f8970901bb0bcadb8703f74db0f781627ea0 (patch) | |
| tree | 51b2604ec1630ff98eee756a73f115708ee55be7 /frontend | |
| parent | frontend: revert (diff) | |
| download | lphub-bbd8f8970901bb0bcadb8703f74db0f781627ea0.tar.gz lphub-bbd8f8970901bb0bcadb8703f74db0f781627ea0.tar.bz2 lphub-bbd8f8970901bb0bcadb8703f74db0f781627ea0.zip | |
frontend: maplist chapter param fix
Diffstat (limited to 'frontend')
| -rw-r--r-- | frontend/src/pages/Maplist.tsx | 14 |
1 files changed, 7 insertions, 7 deletions
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 = () => { | |||
| 21 | 21 | ||
| 22 | const [dropdownActive, setDropdownActive] = React.useState("none"); | 22 | const [dropdownActive, setDropdownActive] = React.useState("none"); |
| 23 | 23 | ||
| 24 | const params = useParams<{ id: string }>(); | 24 | const params = useParams<{ id: string, chapter: string }>(); |
| 25 | const location = useLocation(); | 25 | const location = useLocation(); |
| 26 | const navigate = useNavigate(); | 26 | const navigate = useNavigate(); |
| 27 | 27 | ||
| @@ -52,11 +52,10 @@ const Maplist: React.FC = () => { | |||
| 52 | 52 | ||
| 53 | // location query params | 53 | // location query params |
| 54 | const queryParams = new URLSearchParams(location.search); | 54 | const queryParams = new URLSearchParams(location.search); |
| 55 | if (queryParams.get("cat")) { | 55 | if (queryParams.get("chapter")) { |
| 56 | const cat = parseFloat(queryParams.get("cat") || ""); | 56 | const cat = parseFloat(queryParams.get("chapter") || ""); |
| 57 | setCategory(cat); | 57 | _fetch_chapters(cat.toString()); |
| 58 | setCatNum(cat - 1); | 58 | } |
| 59 | } | ||
| 60 | 59 | ||
| 61 | const _fetch_game = async () => { | 60 | const _fetch_game = async () => { |
| 62 | const games = await API.get_games(); | 61 | const games = await API.get_games(); |
| @@ -80,7 +79,8 @@ const Maplist: React.FC = () => { | |||
| 80 | }, []); | 79 | }, []); |
| 81 | 80 | ||
| 82 | useEffect(() => { | 81 | useEffect(() => { |
| 83 | if (gameChapters != undefined) { | 82 | const queryParams = new URLSearchParams(location.search); |
| 83 | if (gameChapters != undefined && queryParams.get("chapter") == "") { | ||
| 84 | _fetch_chapters(gameChapters!.chapters[0].id.toString()); | 84 | _fetch_chapters(gameChapters!.chapters[0].id.toString()); |
| 85 | } | 85 | } |
| 86 | }, [gameChapters]) | 86 | }, [gameChapters]) |