diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-09-09 19:29:42 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-09-09 19:29:42 +0300 |
| commit | 89560a61bc6e41d86acaea596762eda2da38fe50 (patch) | |
| tree | 1cf4b7c73c17f045d3f4837b480ddf7a61230a94 /frontend/src/App.tsx | |
| parent | refactor: rankings page (diff) | |
| download | lphub-89560a61bc6e41d86acaea596762eda2da38fe50.tar.gz lphub-89560a61bc6e41d86acaea596762eda2da38fe50.tar.bz2 lphub-89560a61bc6e41d86acaea596762eda2da38fe50.zip | |
refactor: upload run form, lots of random shit
Diffstat (limited to 'frontend/src/App.tsx')
| -rw-r--r-- | frontend/src/App.tsx | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index d45cd97..095cbbe 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx | |||
| @@ -10,6 +10,10 @@ import Games from './pages/Games'; | |||
| 10 | import Maps from './pages/Maps'; | 10 | import Maps from './pages/Maps'; |
| 11 | import User from './pages/User'; | 11 | import User from './pages/User'; |
| 12 | import Homepage from './pages/Homepage'; | 12 | import Homepage from './pages/Homepage'; |
| 13 | import UploadRunDialog from './components/UploadRunDialog'; | ||
| 14 | import About from './pages/About'; | ||
| 15 | import { Game } from './types/Game'; | ||
| 16 | import { API } from './api/Api'; | ||
| 13 | import Maplist from './pages/Maplist'; | 17 | import Maplist from './pages/Maplist'; |
| 14 | import Rankings from './pages/Rankings'; | 18 | import Rankings from './pages/Rankings'; |
| 15 | 19 | ||
| @@ -18,22 +22,44 @@ const App: React.FC = () => { | |||
| 18 | const [profile, setProfile] = React.useState<UserProfile | undefined>(undefined); | 22 | const [profile, setProfile] = React.useState<UserProfile | undefined>(undefined); |
| 19 | const [isModerator, setIsModerator] = React.useState<boolean>(true); | 23 | const [isModerator, setIsModerator] = React.useState<boolean>(true); |
| 20 | 24 | ||
| 25 | const [games, setGames] = React.useState<Game[]>([]); | ||
| 26 | |||
| 27 | const [uploadRunDialog, setUploadRunDialog] = React.useState<boolean>(false); | ||
| 28 | const [uploadRunDialogMapID, setUploadRunDialogMapID] = React.useState<number | undefined>(undefined); | ||
| 29 | |||
| 21 | // React.useEffect(() => { | 30 | // React.useEffect(() => { |
| 22 | // if (token) { | 31 | // if (token) { |
| 23 | // setIsModerator(JSON.parse(atob(token.split(".")[1])).mod) | 32 | // setIsModerator(JSON.parse(atob(token.split(".")[1])).mod) |
| 24 | // } | 33 | // } |
| 25 | // }, [token]); | 34 | // }, [token]); |
| 26 | 35 | ||
| 36 | const _fetch_games = async () => { | ||
| 37 | const games = await API.get_games(); | ||
| 38 | setGames(games); | ||
| 39 | }; | ||
| 40 | |||
| 41 | React.useEffect(() => { | ||
| 42 | _fetch_games(); | ||
| 43 | }, []); | ||
| 44 | |||
| 45 | if (!games) { | ||
| 46 | return ( | ||
| 47 | <></> | ||
| 48 | ) | ||
| 49 | }; | ||
| 50 | |||
| 27 | return ( | 51 | return ( |
| 28 | <> | 52 | <> |
| 29 | <Sidebar setToken={setToken} profile={profile} setProfile={setProfile} /> | 53 | <UploadRunDialog open={uploadRunDialog} onClose={() => setUploadRunDialog(false)} mapID={uploadRunDialogMapID} games={games} /> |
| 54 | <Sidebar setToken={setToken} profile={profile} setProfile={setProfile} onUploadRun={() => setUploadRunDialog(true)} /> | ||
| 30 | <Routes> | 55 | <Routes> |
| 31 | <Route path="/" element={<Homepage />} /> | 56 | <Route path="/" element={<Homepage />} /> |
| 32 | <Route path="/profile" element={<Profile profile={profile} />} /> | 57 | <Route path="/profile" element={<Profile profile={profile} />} /> |
| 33 | <Route path="/users/*" element={<User />} /> | 58 | <Route path="/users/*" element={<User />} /> |
| 34 | <Route path="/games" element={<Games />} /> | 59 | <Route path="/games" element={<Games games={games} />} /> |
| 35 | <Route path="/maps/*" element={<Maps isModerator={isModerator} />} /> | 60 | <Route path='/games/:id' element={<Maplist />}></Route> |
| 36 | <Route path='/games/:id' element={<Maplist></Maplist>}></Route> | 61 | <Route path="/maps/*" element={<Maps profile={profile} isModerator={isModerator} onUploadRun={(mapID) => {setUploadRunDialog(true);setUploadRunDialogMapID(mapID)}} />}/> |
| 62 | <Route path="/about" element={<About />} /> | ||
| 37 | <Route path='/rankings' element={<Rankings></Rankings>}></Route> | 63 | <Route path='/rankings' element={<Rankings></Rankings>}></Route> |
| 38 | <Route path="*" element={"404"} /> | 64 | <Route path="*" element={"404"} /> |
| 39 | </Routes> | 65 | </Routes> |