diff options
| author | Wolfboy248 <georgejvindkarlsen@gmail.com> | 2025-08-19 13:23:56 +0200 |
|---|---|---|
| committer | Wolfboy248 <georgejvindkarlsen@gmail.com> | 2025-08-19 13:23:56 +0200 |
| commit | 97be0afd140c7c9e1fd03ba5ab4e486d90907129 (patch) | |
| tree | ab9dcf8ebab077b5fc7ab149c6ce8c13c21caaab /frontend/src/pages/Maps.tsx | |
| parent | organised pages, started work on theme (diff) | |
| download | lphub-97be0afd140c7c9e1fd03ba5ab4e486d90907129.tar.gz lphub-97be0afd140c7c9e1fd03ba5ab4e486d90907129.tar.bz2 lphub-97be0afd140c7c9e1fd03ba5ab4e486d90907129.zip | |
organised pages, started work on theme
Diffstat (limited to 'frontend/src/pages/Maps.tsx')
| -rw-r--r-- | frontend/src/pages/Maps.tsx | 185 |
1 files changed, 0 insertions, 185 deletions
diff --git a/frontend/src/pages/Maps.tsx b/frontend/src/pages/Maps.tsx deleted file mode 100644 index 50fe03b..0000000 --- a/frontend/src/pages/Maps.tsx +++ /dev/null | |||
| @@ -1,185 +0,0 @@ | |||
| 1 | import React from "react"; | ||
| 2 | import { Link, useLocation } from "react-router-dom"; | ||
| 3 | import { Helmet } from "react-helmet"; | ||
| 4 | |||
| 5 | import { PortalIcon, FlagIcon, ChatIcon } from "../images/Images"; | ||
| 6 | import Summary from "@components/Summary"; | ||
| 7 | import Leaderboards from "@components/Leaderboards"; | ||
| 8 | import Discussions from "@components/Discussions"; | ||
| 9 | import ModMenu from "@components/ModMenu"; | ||
| 10 | import { MapDiscussions, MapLeaderboard, MapSummary } from "@customTypes/Map"; | ||
| 11 | import { API } from "@api/Api"; | ||
| 12 | |||
| 13 | interface MapProps { | ||
| 14 | token?: string; | ||
| 15 | isModerator: boolean; | ||
| 16 | } | ||
| 17 | |||
| 18 | const Maps: React.FC<MapProps> = ({ token, isModerator }) => { | ||
| 19 | const [selectedRun, setSelectedRun] = React.useState<number>(0); | ||
| 20 | |||
| 21 | const [mapSummaryData, setMapSummaryData] = React.useState< | ||
| 22 | MapSummary | undefined | ||
| 23 | >(undefined); | ||
| 24 | const [mapLeaderboardData, setMapLeaderboardData] = React.useState< | ||
| 25 | MapLeaderboard | undefined | ||
| 26 | >(undefined); | ||
| 27 | const [mapDiscussionsData, setMapDiscussionsData] = React.useState< | ||
| 28 | MapDiscussions | undefined | ||
| 29 | >(undefined); | ||
| 30 | |||
| 31 | const [navState, setNavState] = React.useState<number>(0); | ||
| 32 | |||
| 33 | const location = useLocation(); | ||
| 34 | |||
| 35 | const mapID = location.pathname.split("/")[2]; | ||
| 36 | |||
| 37 | const _fetch_map_summary = React.useCallback(async () => { | ||
| 38 | const mapSummary = await API.get_map_summary(mapID); | ||
| 39 | setMapSummaryData(mapSummary); | ||
| 40 | }, [mapID]); | ||
| 41 | |||
| 42 | const _fetch_map_leaderboards = React.useCallback(async () => { | ||
| 43 | const mapLeaderboards = await API.get_map_leaderboard(mapID, "1"); | ||
| 44 | setMapLeaderboardData(mapLeaderboards); | ||
| 45 | }, [mapID]); | ||
| 46 | |||
| 47 | const _fetch_map_discussions = React.useCallback(async () => { | ||
| 48 | const mapDiscussions = await API.get_map_discussions(mapID); | ||
| 49 | setMapDiscussionsData(mapDiscussions); | ||
| 50 | }, [mapID]); | ||
| 51 | |||
| 52 | React.useEffect(() => { | ||
| 53 | _fetch_map_summary(); | ||
| 54 | _fetch_map_leaderboards(); | ||
| 55 | _fetch_map_discussions(); | ||
| 56 | }, [ | ||
| 57 | mapID, | ||
| 58 | _fetch_map_discussions, | ||
| 59 | _fetch_map_leaderboards, | ||
| 60 | _fetch_map_summary, | ||
| 61 | ]); | ||
| 62 | |||
| 63 | if (!mapSummaryData) { | ||
| 64 | // loading placeholder | ||
| 65 | return ( | ||
| 66 | <> | ||
| 67 | <main className="*:text-foreground relative left-0 w-[calc(100%-20rem)] min-h-screen p-4 sm:p-8"> | ||
| 68 | <section id="section1" className="summary1"> | ||
| 69 | <div> | ||
| 70 | <Link to="/games"> | ||
| 71 | <button | ||
| 72 | className="nav-button rounded-[20px] h-10 bg-surface border-0 text-foreground text-lg font-[--font-barlow-semicondensed-regular] transition-colors duration-100 hover:bg-surface2 flex items-center px-2" | ||
| 73 | > | ||
| 74 | <i className="triangle"></i> | ||
| 75 | <span className="px-2">Games List</span> | ||
| 76 | </button> | ||
| 77 | </Link> | ||
| 78 | </div> | ||
| 79 | </section> | ||
| 80 | |||
| 81 | <section id="section2" className="summary1 mt-4 flex gap-2 flex-wrap"> | ||
| 82 | <button className="nav-button"> | ||
| 83 | <img src={PortalIcon} alt="" className="w-5 h-5 sm:w-6 sm:h-6" /> | ||
| 84 | <span>Summary</span> | ||
| 85 | </button> | ||
| 86 | <button className="nav-button"> | ||
| 87 | <img src={FlagIcon} alt="" className="w-5 h-5 sm:w-6 sm:h-6" /> | ||
| 88 | <span>Leaderboards</span> | ||
| 89 | </button> | ||
| 90 | <button className="nav-button"> | ||
| 91 | <img src={ChatIcon} alt="" className="w-5 h-5 sm:w-6 sm:h-6" /> | ||
| 92 | <span>Discussions</span> | ||
| 93 | </button> | ||
| 94 | </section> | ||
| 95 | |||
| 96 | <section id="section6" className="summary2 mt-4" /> | ||
| 97 | </main> | ||
| 98 | </> | ||
| 99 | ); | ||
| 100 | } | ||
| 101 | |||
| 102 | return ( | ||
| 103 | <> | ||
| 104 | <Helmet> | ||
| 105 | <title>LPHUB | {mapSummaryData.map.map_name}</title> | ||
| 106 | <meta name="description" content={mapSummaryData.map.map_name} /> | ||
| 107 | </Helmet> | ||
| 108 | {isModerator && ( | ||
| 109 | <ModMenu | ||
| 110 | token={token} | ||
| 111 | data={mapSummaryData} | ||
| 112 | selectedRun={selectedRun} | ||
| 113 | mapID={mapID} | ||
| 114 | /> | ||
| 115 | )} | ||
| 116 | |||
| 117 | <div id="background-image"> | ||
| 118 | <img src={mapSummaryData.map.image} alt="" /> | ||
| 119 | </div> | ||
| 120 | <main className="relative left-0 w-full sm:ml-80 sm:w-[calc(100%-20rem)] min-h-screen max-h-screen overflow-y-auto p-4 sm:p-8 scrollbar-thin scrollbar-track-surface scrollbar-thumb-muted hover:scrollbar-thumb-surface1"> | ||
| 121 | <section id="section1" className="summary1"> | ||
| 122 | <div> | ||
| 123 | <Link to="/games"> | ||
| 124 | <button | ||
| 125 | className="nav-button rounded-[20px] h-10 bg-surface border-0 text-foreground text-lg font-[--font-barlow-semicondensed-regular] transition-colors duration-100 hover:bg-surface2 flex items-center px-2" | ||
| 126 | > | ||
| 127 | <i className="triangle"></i> | ||
| 128 | <span className="px-2">Games List</span> | ||
| 129 | </button> | ||
| 130 | </Link> | ||
| 131 | <Link | ||
| 132 | to={`/games/${mapSummaryData.map.is_coop ? "2" : "1"}?chapter=${mapSummaryData.map.chapter_name.split(" ")[1]}`} | ||
| 133 | > | ||
| 134 | <button | ||
| 135 | className="nav-button ml-2" | ||
| 136 | > | ||
| 137 | <i className="triangle"></i> | ||
| 138 | <span className="px-2">{mapSummaryData.map.chapter_name}</span> | ||
| 139 | </button> | ||
| 140 | </Link> | ||
| 141 | <br /> | ||
| 142 | <span className="block mt-2 text-lg sm:text-xl text-foreground"> | ||
| 143 | <b>{mapSummaryData.map.map_name}</b> | ||
| 144 | </span> | ||
| 145 | </div> | ||
| 146 | </section> | ||
| 147 | |||
| 148 | <section id="section2" className="summary1 mt-4 flex gap-2 flex-wrap"> | ||
| 149 | <button className="nav-button" onClick={() => setNavState(0)}> | ||
| 150 | <img src={PortalIcon} alt="" className="w-5 h-5 sm:w-6 sm:h-6" /> | ||
| 151 | <span>Summary</span> | ||
| 152 | </button> | ||
| 153 | <button className="nav-button" onClick={() => setNavState(1)}> | ||
| 154 | <img src={FlagIcon} alt="" className="w-5 h-5 sm:w-6 sm:h-6" /> | ||
| 155 | <span>Leaderboards</span> | ||
| 156 | </button> | ||
| 157 | <button className="nav-button" onClick={() => setNavState(2)}> | ||
| 158 | <img src={ChatIcon} alt="" className="w-5 h-5 sm:w-6 sm:h-6" /> | ||
| 159 | <span>Discussions</span> | ||
| 160 | </button> | ||
| 161 | </section> | ||
| 162 | |||
| 163 | {navState === 0 && ( | ||
| 164 | <Summary | ||
| 165 | selectedRun={selectedRun} | ||
| 166 | setSelectedRun={setSelectedRun} | ||
| 167 | data={mapSummaryData} | ||
| 168 | /> | ||
| 169 | )} | ||
| 170 | {navState === 1 && <Leaderboards mapID={mapID} />} | ||
| 171 | {navState === 2 && ( | ||
| 172 | <Discussions | ||
| 173 | data={mapDiscussionsData} | ||
| 174 | token={token} | ||
| 175 | isModerator={isModerator} | ||
| 176 | mapID={mapID} | ||
| 177 | onRefresh={() => _fetch_map_discussions()} | ||
| 178 | /> | ||
| 179 | )} | ||
| 180 | </main> | ||
| 181 | </> | ||
| 182 | ); | ||
| 183 | }; | ||
| 184 | |||
| 185 | export default Maps; | ||