aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/api/Mod.ts
blob: d682f1a8ffcd66777a04f7a7da4e85d93ad2fe4e (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import axios from "axios";
import { url } from "@api/Api";
import { ModMenuContent } from "@customTypes/Content";

export const put_map_image = async (
  token: string,
  map_id: string,
  image: string
): Promise<boolean> => {
  const response = await axios.put(
    url(`maps/${map_id}/image`),
    {
      image: image,
    },
    {
      headers: {
        Authorization: token,
      },
    }
  );
  return response.data.success;
};

export const post_map_summary = async (
  token: string,
  map_id: string,
  content: ModMenuContent
): Promise<boolean> => {
  const response = await axios.post(
    url(`maps/${map_id}/summary`),
    {
      category_id: content.category_id,
      user_name: content.name,
      score_count: content.score,
      record_date: content.date,
      showcase: content.showcase,
      description: content.description,
    },
    {
      headers: {
        Authorization: token,
      },
    }
  );
  return response.data.success;
};

export const put_map_summary = async (
  token: string,
  map_id: string,
  content: ModMenuContent
): Promise<boolean> => {
  const response = await axios.put(
    url(`maps/${map_id}/summary`),
    {
      route_id: content.id,
      user_name: content.name,
      score_count: content.score,
      record_date: content.date,
      showcase: content.showcase,
      description: content.description,
    },
    {
      headers: {
        Authorization: token,
      },
    }
  );
  return response.data.success;
};

export const delete_map_summary = async (
  token: string,
  map_id: string,
  route_id: number
): Promise<boolean> => {
  const response = await axios.delete(url(`maps/${map_id}/summary`), {
    data: {
      route_id: route_id,
    },
    headers: {
      Authorization: token,
    },
  });
  return response.data.success;
};