diff options
Diffstat (limited to 'frontend/src/api/Mod.ts')
| -rw-r--r-- | frontend/src/api/Mod.ts | 104 |
1 files changed, 66 insertions, 38 deletions
diff --git a/frontend/src/api/Mod.ts b/frontend/src/api/Mod.ts index 1511f8b..69e76c5 100644 --- a/frontend/src/api/Mod.ts +++ b/frontend/src/api/Mod.ts | |||
| @@ -1,58 +1,86 @@ | |||
| 1 | import axios from "axios"; | 1 | import axios from 'axios'; |
| 2 | import { url } from "@api/Api"; | 2 | import { url } from '@api/Api'; |
| 3 | import { ModMenuContent } from "@customTypes/Content"; | 3 | import { ModMenuContent } from '@customTypes/Content'; |
| 4 | 4 | ||
| 5 | export const put_map_image = async (token: string, map_id: string, image: string): Promise<boolean> => { | 5 | export const put_map_image = async ( |
| 6 | const response = await axios.put(url(`maps/${map_id}/image`), { | 6 | token: string, |
| 7 | "image": image, | 7 | map_id: string, |
| 8 | }, { | 8 | image: string |
| 9 | headers: { | 9 | ): Promise<boolean> => { |
| 10 | "Authorization": token, | 10 | const response = await axios.put( |
| 11 | url(`maps/${map_id}/image`), | ||
| 12 | { | ||
| 13 | image: image, | ||
| 14 | }, | ||
| 15 | { | ||
| 16 | headers: { | ||
| 17 | Authorization: token, | ||
| 18 | }, | ||
| 11 | } | 19 | } |
| 12 | }); | 20 | ); |
| 13 | return response.data.success; | 21 | return response.data.success; |
| 14 | }; | 22 | }; |
| 15 | 23 | ||
| 16 | export const post_map_summary = async (token: string, map_id: string, content: ModMenuContent): Promise<boolean> => { | 24 | export const post_map_summary = async ( |
| 17 | const response = await axios.post(url(`maps/${map_id}/summary`), { | 25 | token: string, |
| 18 | "category_id": content.category_id, | 26 | map_id: string, |
| 19 | "user_name": content.name, | 27 | content: ModMenuContent |
| 20 | "score_count": content.score, | 28 | ): Promise<boolean> => { |
| 21 | "record_date": content.date, | 29 | const response = await axios.post( |
| 22 | "showcase": content.showcase, | 30 | url(`maps/${map_id}/summary`), |
| 23 | "description": content.description, | 31 | { |
| 24 | }, { | 32 | category_id: content.category_id, |
| 25 | headers: { | 33 | user_name: content.name, |
| 26 | "Authorization": token, | 34 | score_count: content.score, |
| 35 | record_date: content.date, | ||
| 36 | showcase: content.showcase, | ||
| 37 | description: content.description, | ||
| 38 | }, | ||
| 39 | { | ||
| 40 | headers: { | ||
| 41 | Authorization: token, | ||
| 42 | }, | ||
| 27 | } | 43 | } |
| 28 | }); | 44 | ); |
| 29 | return response.data.success; | 45 | return response.data.success; |
| 30 | }; | 46 | }; |
| 31 | 47 | ||
| 32 | export const put_map_summary = async (token: string, map_id: string, content: ModMenuContent): Promise<boolean> => { | 48 | export const put_map_summary = async ( |
| 33 | const response = await axios.put(url(`maps/${map_id}/summary`), { | 49 | token: string, |
| 34 | "route_id": content.id, | 50 | map_id: string, |
| 35 | "user_name": content.name, | 51 | content: ModMenuContent |
| 36 | "score_count": content.score, | 52 | ): Promise<boolean> => { |
| 37 | "record_date": content.date, | 53 | const response = await axios.put( |
| 38 | "showcase": content.showcase, | 54 | url(`maps/${map_id}/summary`), |
| 39 | "description": content.description, | 55 | { |
| 40 | }, { | 56 | route_id: content.id, |
| 41 | headers: { | 57 | user_name: content.name, |
| 42 | "Authorization": token, | 58 | score_count: content.score, |
| 59 | record_date: content.date, | ||
| 60 | showcase: content.showcase, | ||
| 61 | description: content.description, | ||
| 62 | }, | ||
| 63 | { | ||
| 64 | headers: { | ||
| 65 | Authorization: token, | ||
| 66 | }, | ||
| 43 | } | 67 | } |
| 44 | }); | 68 | ); |
| 45 | return response.data.success; | 69 | return response.data.success; |
| 46 | }; | 70 | }; |
| 47 | 71 | ||
| 48 | export const delete_map_summary = async (token: string, map_id: string, route_id: number): Promise<boolean> => { | 72 | export const delete_map_summary = async ( |
| 73 | token: string, | ||
| 74 | map_id: string, | ||
| 75 | route_id: number | ||
| 76 | ): Promise<boolean> => { | ||
| 49 | const response = await axios.delete(url(`maps/${map_id}/summary`), { | 77 | const response = await axios.delete(url(`maps/${map_id}/summary`), { |
| 50 | data: { | 78 | data: { |
| 51 | "route_id": route_id, | 79 | route_id: route_id, |
| 52 | }, | 80 | }, |
| 53 | headers: { | 81 | headers: { |
| 54 | "Authorization": token, | 82 | Authorization: token, |
| 55 | } | 83 | }, |
| 56 | }); | 84 | }); |
| 57 | return response.data.success; | 85 | return response.data.success; |
| 58 | }; | 86 | }; |