aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/api/Games.ts
blob: 0e47091793f2b80653b65454929a0b2c3cb94588 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import axios from 'axios';
import { url } from '@api/Api';
import { GameChapter, GamesChapters } from '@customTypes/Chapters';
import { Game } from '@customTypes/Game';
import { Map } from '@customTypes/Map';
import { Search } from '@customTypes/Search';

export const get_games = async (): Promise<Game[]> => {
  const response = await axios.get(url(`games`));
  return response.data.data;
};

export const get_chapters = async (
  chapter_id: string
): Promise<GameChapter> => {
  const response = await axios.get(url(`chapters/${chapter_id}`));
  return response.data.data;
};

export const get_games_chapters = async (
  game_id: string
): Promise<GamesChapters> => {
  const response = await axios.get(url(`games/${game_id}`));
  return response.data.data;
};

export const get_game_maps = async (game_id: string): Promise<Map[]> => {
  const response = await axios.get(url(`games/${game_id}/maps`));
  return response.data.data.maps;
};

export const get_search = async (q: string): Promise<Search> => {
  const response = await axios.get(url(`search?q=${q}`));
  return response.data.data;
};