diff options
| author | FifthWit <fifthwitbusiness@gmail.com> | 2025-01-30 10:44:30 -0600 |
|---|---|---|
| committer | FifthWit <fifthwitbusiness@gmail.com> | 2025-01-30 10:44:30 -0600 |
| commit | e40f07211f5f15dcb138e2520a76d13afd3c0cfd (patch) | |
| tree | 46bad6a17e66d55a4a65088c0b6eb8c48641615a /frontend/src/pages/Maps.tsx | |
| parent | added prettier for more consistency (diff) | |
| download | lphub-e40f07211f5f15dcb138e2520a76d13afd3c0cfd.tar.gz lphub-e40f07211f5f15dcb138e2520a76d13afd3c0cfd.tar.bz2 lphub-e40f07211f5f15dcb138e2520a76d13afd3c0cfd.zip | |
formatted with prettier
Diffstat (limited to 'frontend/src/pages/Maps.tsx')
| -rw-r--r-- | frontend/src/pages/Maps.tsx | 129 |
1 files changed, 101 insertions, 28 deletions
diff --git a/frontend/src/pages/Maps.tsx b/frontend/src/pages/Maps.tsx index fb13563..51a2020 100644 --- a/frontend/src/pages/Maps.tsx +++ b/frontend/src/pages/Maps.tsx | |||
| @@ -9,26 +9,31 @@ import Discussions from '@components/Discussions'; | |||
| 9 | import ModMenu from '@components/ModMenu'; | 9 | import ModMenu from '@components/ModMenu'; |
| 10 | import { MapDiscussions, MapLeaderboard, MapSummary } from '@customTypes/Map'; | 10 | import { MapDiscussions, MapLeaderboard, MapSummary } from '@customTypes/Map'; |
| 11 | import { API } from '@api/Api'; | 11 | import { API } from '@api/Api'; |
| 12 | import "@css/Maps.css"; | 12 | import '@css/Maps.css'; |
| 13 | 13 | ||
| 14 | interface MapProps { | 14 | interface MapProps { |
| 15 | token?: string; | 15 | token?: string; |
| 16 | isModerator: boolean; | 16 | isModerator: boolean; |
| 17 | }; | 17 | } |
| 18 | 18 | ||
| 19 | const Maps: React.FC<MapProps> = ({ token, isModerator }) => { | 19 | const Maps: React.FC<MapProps> = ({ token, isModerator }) => { |
| 20 | |||
| 21 | const [selectedRun, setSelectedRun] = React.useState<number>(0); | 20 | const [selectedRun, setSelectedRun] = React.useState<number>(0); |
| 22 | 21 | ||
| 23 | const [mapSummaryData, setMapSummaryData] = React.useState<MapSummary | undefined>(undefined); | 22 | const [mapSummaryData, setMapSummaryData] = React.useState< |
| 24 | const [mapLeaderboardData, setMapLeaderboardData] = React.useState<MapLeaderboard | undefined>(undefined); | 23 | MapSummary | undefined |
| 25 | const [mapDiscussionsData, setMapDiscussionsData] = React.useState<MapDiscussions | undefined>(undefined); | 24 | >(undefined); |
| 25 | const [mapLeaderboardData, setMapLeaderboardData] = React.useState< | ||
| 26 | MapLeaderboard | undefined | ||
| 27 | >(undefined); | ||
| 28 | const [mapDiscussionsData, setMapDiscussionsData] = React.useState< | ||
| 29 | MapDiscussions | undefined | ||
| 30 | >(undefined); | ||
| 26 | 31 | ||
| 27 | const [navState, setNavState] = React.useState<number>(0); | 32 | const [navState, setNavState] = React.useState<number>(0); |
| 28 | 33 | ||
| 29 | const location = useLocation(); | 34 | const location = useLocation(); |
| 30 | 35 | ||
| 31 | const mapID = location.pathname.split("/")[2]; | 36 | const mapID = location.pathname.split('/')[2]; |
| 32 | 37 | ||
| 33 | const _fetch_map_summary = async () => { | 38 | const _fetch_map_summary = async () => { |
| 34 | const mapSummary = await API.get_map_summary(mapID); | 39 | const mapSummary = await API.get_map_summary(mapID); |
| @@ -36,7 +41,7 @@ const Maps: React.FC<MapProps> = ({ token, isModerator }) => { | |||
| 36 | }; | 41 | }; |
| 37 | 42 | ||
| 38 | const _fetch_map_leaderboards = async () => { | 43 | const _fetch_map_leaderboards = async () => { |
| 39 | const mapLeaderboards = await API.get_map_leaderboard(mapID, "1"); | 44 | const mapLeaderboards = await API.get_map_leaderboard(mapID, '1'); |
| 40 | setMapLeaderboardData(mapLeaderboards); | 45 | setMapLeaderboardData(mapLeaderboards); |
| 41 | }; | 46 | }; |
| 42 | 47 | ||
| @@ -56,19 +61,36 @@ const Maps: React.FC<MapProps> = ({ token, isModerator }) => { | |||
| 56 | return ( | 61 | return ( |
| 57 | <> | 62 | <> |
| 58 | <main> | 63 | <main> |
| 59 | <section id='section1' className='summary1'> | 64 | <section id="section1" className="summary1"> |
| 60 | <div> | 65 | <div> |
| 61 | <Link to="/games"><button className='nav-button' style={{ borderRadius: "20px 20px 20px 20px" }}><i className='triangle'></i><span>Games List</span></button></Link> | 66 | <Link to="/games"> |
| 67 | <button | ||
| 68 | className="nav-button" | ||
| 69 | style={{ borderRadius: '20px 20px 20px 20px' }} | ||
| 70 | > | ||
| 71 | <i className="triangle"></i> | ||
| 72 | <span>Games List</span> | ||
| 73 | </button> | ||
| 74 | </Link> | ||
| 62 | </div> | 75 | </div> |
| 63 | </section> | 76 | </section> |
| 64 | 77 | ||
| 65 | <section id='section2' className='summary1'> | 78 | <section id="section2" className="summary1"> |
| 66 | <button className='nav-button'><img src={PortalIcon} alt="" /><span>Summary</span></button> | 79 | <button className="nav-button"> |
| 67 | <button className='nav-button'><img src={FlagIcon} alt="" /><span>Leaderboards</span></button> | 80 | <img src={PortalIcon} alt="" /> |
| 68 | <button className='nav-button'><img src={ChatIcon} alt="" /><span>Discussions</span></button> | 81 | <span>Summary</span> |
| 82 | </button> | ||
| 83 | <button className="nav-button"> | ||
| 84 | <img src={FlagIcon} alt="" /> | ||
| 85 | <span>Leaderboards</span> | ||
| 86 | </button> | ||
| 87 | <button className="nav-button"> | ||
| 88 | <img src={ChatIcon} alt="" /> | ||
| 89 | <span>Discussions</span> | ||
| 90 | </button> | ||
| 69 | </section> | 91 | </section> |
| 70 | 92 | ||
| 71 | <section id='section6' className='summary2' /> | 93 | <section id="section6" className="summary2" /> |
| 72 | </main> | 94 | </main> |
| 73 | </> | 95 | </> |
| 74 | ); | 96 | ); |
| @@ -80,29 +102,80 @@ const Maps: React.FC<MapProps> = ({ token, isModerator }) => { | |||
| 80 | <title>LPHUB | {mapSummaryData.map.map_name}</title> | 102 | <title>LPHUB | {mapSummaryData.map.map_name}</title> |
| 81 | <meta name="description" content={mapSummaryData.map.map_name} /> | 103 | <meta name="description" content={mapSummaryData.map.map_name} /> |
| 82 | </Helmet> | 104 | </Helmet> |
| 83 | {isModerator && <ModMenu token={token} data={mapSummaryData} selectedRun={selectedRun} mapID={mapID} />} | 105 | {isModerator && ( |
| 84 | 106 | <ModMenu | |
| 85 | <div id='background-image'> | 107 | token={token} |
| 108 | data={mapSummaryData} | ||
| 109 | selectedRun={selectedRun} | ||
| 110 | mapID={mapID} | ||
| 111 | /> | ||
| 112 | )} | ||
| 113 | |||
| 114 | <div id="background-image"> | ||
| 86 | <img src={mapSummaryData.map.image} alt="" /> | 115 | <img src={mapSummaryData.map.image} alt="" /> |
| 87 | </div> | 116 | </div> |
| 88 | <main> | 117 | <main> |
| 89 | <section id='section1' className='summary1'> | 118 | <section id="section1" className="summary1"> |
| 90 | <div> | 119 | <div> |
| 91 | <Link to="/games"><button className='nav-button' style={{ borderRadius: "20px 0px 0px 20px" }}><i className='triangle'></i><span>Games List</span></button></Link> | 120 | <Link to="/games"> |
| 92 | <Link to={`/games/${mapSummaryData.map.is_coop ? "2" : "1"}?chapter=${mapSummaryData.map.chapter_name.split(" ")[1]}`}><button className='nav-button' style={{ borderRadius: "0px 20px 20px 0px", marginLeft: "2px" }}><i className='triangle'></i><span>{mapSummaryData.map.chapter_name}</span></button></Link> | 121 | <button |
| 93 | <br /><span><b>{mapSummaryData.map.map_name}</b></span> | 122 | className="nav-button" |
| 123 | style={{ borderRadius: '20px 0px 0px 20px' }} | ||
| 124 | > | ||
| 125 | <i className="triangle"></i> | ||
| 126 | <span>Games List</span> | ||
| 127 | </button> | ||
| 128 | </Link> | ||
| 129 | <Link | ||
| 130 | to={`/games/${mapSummaryData.map.is_coop ? '2' : '1'}?chapter=${mapSummaryData.map.chapter_name.split(' ')[1]}`} | ||
| 131 | > | ||
| 132 | <button | ||
| 133 | className="nav-button" | ||
| 134 | style={{ borderRadius: '0px 20px 20px 0px', marginLeft: '2px' }} | ||
| 135 | > | ||
| 136 | <i className="triangle"></i> | ||
| 137 | <span>{mapSummaryData.map.chapter_name}</span> | ||
| 138 | </button> | ||
| 139 | </Link> | ||
| 140 | <br /> | ||
| 141 | <span> | ||
| 142 | <b>{mapSummaryData.map.map_name}</b> | ||
| 143 | </span> | ||
| 94 | </div> | 144 | </div> |
| 95 | </section> | 145 | </section> |
| 96 | 146 | ||
| 97 | <section id='section2' className='summary1'> | 147 | <section id="section2" className="summary1"> |
| 98 | <button className='nav-button' onClick={() => setNavState(0)}><img src={PortalIcon} alt="" /><span>Summary</span></button> | 148 | <button className="nav-button" onClick={() => setNavState(0)}> |
| 99 | <button className='nav-button' onClick={() => setNavState(1)}><img src={FlagIcon} alt="" /><span>Leaderboards</span></button> | 149 | <img src={PortalIcon} alt="" /> |
| 100 | <button className='nav-button' onClick={() => setNavState(2)}><img src={ChatIcon} alt="" /><span>Discussions</span></button> | 150 | <span>Summary</span> |
| 151 | </button> | ||
| 152 | <button className="nav-button" onClick={() => setNavState(1)}> | ||
| 153 | <img src={FlagIcon} alt="" /> | ||
| 154 | <span>Leaderboards</span> | ||
| 155 | </button> | ||
| 156 | <button className="nav-button" onClick={() => setNavState(2)}> | ||
| 157 | <img src={ChatIcon} alt="" /> | ||
| 158 | <span>Discussions</span> | ||
| 159 | </button> | ||
| 101 | </section> | 160 | </section> |
| 102 | 161 | ||
| 103 | {navState === 0 && <Summary selectedRun={selectedRun} setSelectedRun={setSelectedRun} data={mapSummaryData} />} | 162 | {navState === 0 && ( |
| 163 | <Summary | ||
| 164 | selectedRun={selectedRun} | ||
| 165 | setSelectedRun={setSelectedRun} | ||
| 166 | data={mapSummaryData} | ||
| 167 | /> | ||
| 168 | )} | ||
| 104 | {navState === 1 && <Leaderboards mapID={mapID} />} | 169 | {navState === 1 && <Leaderboards mapID={mapID} />} |
| 105 | {navState === 2 && <Discussions data={mapDiscussionsData} token={token} isModerator={isModerator} mapID={mapID} onRefresh={() => _fetch_map_discussions()} />} | 170 | {navState === 2 && ( |
| 171 | <Discussions | ||
| 172 | data={mapDiscussionsData} | ||
| 173 | token={token} | ||
| 174 | isModerator={isModerator} | ||
| 175 | mapID={mapID} | ||
| 176 | onRefresh={() => _fetch_map_discussions()} | ||
| 177 | /> | ||
| 178 | )} | ||
| 106 | </main> | 179 | </main> |
| 107 | </> | 180 | </> |
| 108 | ); | 181 | ); |