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/components/Leaderboards.tsx | |
| parent | fix/frontend: fixed sidebar title size, removed unnecessary imports (diff) | |
| parent | feat/backend: add newrelic integration (#274) (diff) | |
| download | lphub-b0d199936b546c75d4b19d99591237f0bf97fe55.tar.gz lphub-b0d199936b546c75d4b19d99591237f0bf97fe55.tar.bz2 lphub-b0d199936b546c75d4b19d99591237f0bf97fe55.zip | |
Merge branch 'main' into css-overhaulcss-overhaul
Diffstat (limited to 'frontend/src/components/Leaderboards.tsx')
| -rw-r--r-- | frontend/src/components/Leaderboards.tsx | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/frontend/src/components/Leaderboards.tsx b/frontend/src/components/Leaderboards.tsx index 4a8b463..fb614fa 100644 --- a/frontend/src/components/Leaderboards.tsx +++ b/frontend/src/components/Leaderboards.tsx | |||
| @@ -1,20 +1,33 @@ | |||
| 1 | import React from 'react'; | 1 | import React from 'react'; |
| 2 | import { Link } from 'react-router-dom'; | 2 | import { Link, useNavigate } from 'react-router-dom'; |
| 3 | 3 | ||
| 4 | import { DownloadIcon, ThreedotIcon } from '@images/Images'; | 4 | import { DownloadIcon, ThreedotIcon } from '@images/Images'; |
| 5 | import { MapLeaderboard } from '@customTypes/Map'; | 5 | import { MapLeaderboard } from '@customTypes/Map'; |
| 6 | import { ticks_to_time, time_ago } from '@utils/Time'; | 6 | import { ticks_to_time, time_ago } from '@utils/Time'; |
| 7 | import { API } from "@api/Api"; | ||
| 7 | import useMessage from "@hooks/UseMessage"; | 8 | import useMessage from "@hooks/UseMessage"; |
| 8 | import "@css/Maps.css" | 9 | import "@css/Maps.css" |
| 9 | 10 | ||
| 10 | interface LeaderboardsProps { | 11 | interface LeaderboardsProps { |
| 11 | data?: MapLeaderboard; | 12 | mapID: string; |
| 12 | } | 13 | } |
| 13 | 14 | ||
| 14 | const Leaderboards: React.FC<LeaderboardsProps> = ({ data }) => { | 15 | const Leaderboards: React.FC<LeaderboardsProps> = ({ mapID }) => { |
| 16 | const navigate = useNavigate(); | ||
| 17 | const [data, setData] = React.useState<MapLeaderboard | undefined>(undefined); | ||
| 18 | const [pageNumber, setPageNumber] = React.useState<number>(1); | ||
| 19 | |||
| 20 | const _fetch_map_leaderboards = async () => { | ||
| 21 | const mapLeaderboards = await API.get_map_leaderboard(mapID, pageNumber.toString()); | ||
| 22 | setData(mapLeaderboards); | ||
| 23 | }; | ||
| 15 | 24 | ||
| 16 | const { message, MessageDialogComponent } = useMessage(); | 25 | const { message, MessageDialogComponent } = useMessage(); |
| 17 | const [pageNumber, setPageNumber] = React.useState<number>(1); | 26 | |
| 27 | React.useEffect(() => { | ||
| 28 | _fetch_map_leaderboards(); | ||
| 29 | console.log(data); | ||
| 30 | }, [pageNumber, navigate]) | ||
| 18 | 31 | ||
| 19 | if (!data) { | 32 | if (!data) { |
| 20 | return ( | 33 | return ( |