aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/api/Mod.tsx
blob: 9091379ec17cdac2216f735062a39f8e09af1f70 (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
import axios from "axios";
import { url } from "./Api";
import { ModMenuContent } from "../types/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;
};