From a7c282ca348c1e8e60559e5c064caee28ba11eec Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:34:12 +0300 Subject: refactor: so much shit --- frontend/src/api/Games.tsx | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 frontend/src/api/Games.tsx (limited to 'frontend/src/api/Games.tsx') diff --git a/frontend/src/api/Games.tsx b/frontend/src/api/Games.tsx new file mode 100644 index 0000000..84b5f74 --- /dev/null +++ b/frontend/src/api/Games.tsx @@ -0,0 +1,31 @@ +import axios from "axios"; +import { url } from "./Api"; +import { GameChapter, GamesChapters } from "../types/Chapters"; +import { Game } from "../types/Game"; +import { Map } from "../types/Map"; +import { Search } from "../types/Search"; + +export const get_games = async (): Promise => { + const response = await axios.get(url(`games`)) + return response.data.data; +}; + +export const get_chapters = async (chapter_id: string): Promise => { + const response = await axios.get(url(`chapters/${chapter_id}`)); + return response.data.data; +} + +export const get_games_chapters = async (game_id: string): Promise => { + const response = await axios.get(url(`games/${game_id}`)); + return response.data.data; +}; + +export const get_game_maps = async (game_id: string): Promise => { + const response = await axios.get(url(`games/${game_id}/maps`)) + return response.data.data.maps; +}; + +export const get_search = async (q: string): Promise => { + const response = await axios.get(url(`search?q=${q}`)) + return response.data.data; +}; -- cgit v1.2.3