diff options
| author | Wolfboy248 <121288977+Wolfboy248@users.noreply.github.com> | 2024-09-05 16:48:01 +0200 |
|---|---|---|
| committer | Wolfboy248 <121288977+Wolfboy248@users.noreply.github.com> | 2024-09-05 16:48:01 +0200 |
| commit | dea41ea59c558068078c98dd1758cdba2beceda8 (patch) | |
| tree | 15bd6a8a490bdceb66fa093d2b33c862da81b821 /frontend/src/api/Api.tsx | |
| parent | refactor: fix summary cat change logic (diff) | |
| download | lphub-dea41ea59c558068078c98dd1758cdba2beceda8.tar.gz lphub-dea41ea59c558068078c98dd1758cdba2beceda8.tar.bz2 lphub-dea41ea59c558068078c98dd1758cdba2beceda8.zip | |
refactor: maplist page
Diffstat (limited to 'frontend/src/api/Api.tsx')
| -rw-r--r-- | frontend/src/api/Api.tsx | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/frontend/src/api/Api.tsx b/frontend/src/api/Api.tsx index 9e45bc4..326052f 100644 --- a/frontend/src/api/Api.tsx +++ b/frontend/src/api/Api.tsx | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | import axios from 'axios'; | 1 | import axios from 'axios'; |
| 2 | 2 | ||
| 3 | import { Game } from '../types/Game'; | 3 | import { Game, GameChapters } from '../types/Game'; |
| 4 | import { MapDiscussion, MapDiscussions, MapLeaderboard, MapSummary } from '../types/Map'; | 4 | import { GameChapter, GamesChapters } from '../types/Chapters'; |
| 5 | import { MapDiscussion, MapDiscussions, MapLeaderboard, MapSummary, Map } from '../types/Map'; | ||
| 5 | import { MapDiscussionCommentContent, MapDiscussionContent, ModMenuContent } from '../types/Content'; | 6 | import { MapDiscussionCommentContent, MapDiscussionContent, ModMenuContent } from '../types/Content'; |
| 6 | import { Search } from '../types/Search'; | 7 | import { Search } from '../types/Search'; |
| 7 | import { UserProfile } from '../types/Profile'; | 8 | import { UserProfile } from '../types/Profile'; |
| @@ -13,6 +14,9 @@ export const API = { | |||
| 13 | 14 | ||
| 14 | get_user: (user_id: string) => get_user(user_id), | 15 | get_user: (user_id: string) => get_user(user_id), |
| 15 | get_games: () => get_games(), | 16 | get_games: () => get_games(), |
| 17 | get_chapters: (chapter_id: string) => get_chapters(chapter_id), | ||
| 18 | get_games_chapters: (game_id: string) => get_games_chapters(game_id), | ||
| 19 | get_games_maps: (game_id: string) => get_games_maps(game_id), | ||
| 16 | get_search: (q: string) => get_search(q), | 20 | get_search: (q: string) => get_search(q), |
| 17 | get_map_summary: (map_id: string) => get_map_summary(map_id), | 21 | get_map_summary: (map_id: string) => get_map_summary(map_id), |
| 18 | get_map_leaderboard: (map_id: string) => get_map_leaderboard(map_id), | 22 | get_map_leaderboard: (map_id: string) => get_map_leaderboard(map_id), |
| @@ -55,6 +59,21 @@ const get_games = async (): Promise<Game[]> => { | |||
| 55 | return response.data.data; | 59 | return response.data.data; |
| 56 | }; | 60 | }; |
| 57 | 61 | ||
| 62 | const get_chapters = async (chapter_id: string): Promise<GameChapter> => { | ||
| 63 | const response = await axios.get(url(`chapters/${chapter_id}`)); | ||
| 64 | return response.data.data; | ||
| 65 | } | ||
| 66 | |||
| 67 | const get_games_chapters = async (game_id: string): Promise<GamesChapters> => { | ||
| 68 | const response = await axios.get(url(`games/${game_id}`)); | ||
| 69 | return response.data.data; | ||
| 70 | }; | ||
| 71 | |||
| 72 | const get_games_maps = async (game_id: string): Promise<Map> => { | ||
| 73 | const response = await axios.get(url(`games/${game_id}/maps`)) | ||
| 74 | return response.data.data; | ||
| 75 | } | ||
| 76 | |||
| 58 | // SEARCH | 77 | // SEARCH |
| 59 | 78 | ||
| 60 | const get_search = async (q: string): Promise<Search> => { | 79 | const get_search = async (q: string): Promise<Search> => { |