diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-11-04 13:47:50 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-04 13:47:50 +0300 |
| commit | eae19bb1b047b3568e7a9a624b50e80886e56331 (patch) | |
| tree | aa3215377fd1a7714e4c5763f9abf9d7dc7def2b /frontend/src/api/Games.ts | |
| parent | fix: remove insert trigger on users, check insert user on login err (#224) (diff) | |
| download | lphub-eae19bb1b047b3568e7a9a624b50e80886e56331.tar.gz lphub-eae19bb1b047b3568e7a9a624b50e80886e56331.tar.bz2 lphub-eae19bb1b047b3568e7a9a624b50e80886e56331.zip | |
feat/frontend: optimizing imports, file extensions (#230)
Co-authored-by: FifthWit <fifthwitbusiness@gmail.com>
Diffstat (limited to 'frontend/src/api/Games.ts')
| -rw-r--r-- | frontend/src/api/Games.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/frontend/src/api/Games.ts b/frontend/src/api/Games.ts new file mode 100644 index 0000000..72bb4b3 --- /dev/null +++ b/frontend/src/api/Games.ts | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | import axios from "axios"; | ||
| 2 | import { url } from "@api/Api"; | ||
| 3 | import { GameChapter, GamesChapters } from "@customTypes/Chapters"; | ||
| 4 | import { Game } from "@customTypes/Game"; | ||
| 5 | import { Map } from "@customTypes/Map"; | ||
| 6 | import { Search } from "@customTypes/Search"; | ||
| 7 | |||
| 8 | export const get_games = async (): Promise<Game[]> => { | ||
| 9 | const response = await axios.get(url(`games`)) | ||
| 10 | return response.data.data; | ||
| 11 | }; | ||
| 12 | |||
| 13 | export const get_chapters = async (chapter_id: string): Promise<GameChapter> => { | ||
| 14 | const response = await axios.get(url(`chapters/${chapter_id}`)); | ||
| 15 | return response.data.data; | ||
| 16 | } | ||
| 17 | |||
| 18 | export const get_games_chapters = async (game_id: string): Promise<GamesChapters> => { | ||
| 19 | const response = await axios.get(url(`games/${game_id}`)); | ||
| 20 | return response.data.data; | ||
| 21 | }; | ||
| 22 | |||
| 23 | export const get_game_maps = async (game_id: string): Promise<Map[]> => { | ||
| 24 | const response = await axios.get(url(`games/${game_id}/maps`)) | ||
| 25 | return response.data.data.maps; | ||
| 26 | }; | ||
| 27 | |||
| 28 | export const get_search = async (q: string): Promise<Search> => { | ||
| 29 | const response = await axios.get(url(`search?q=${q}`)) | ||
| 30 | return response.data.data; | ||
| 31 | }; | ||