diff options
Diffstat (limited to 'frontend/src/api')
| -rw-r--r-- | frontend/src/api/Api.ts | 90 | ||||
| -rw-r--r-- | frontend/src/api/Auth.ts | 2 | ||||
| -rw-r--r-- | frontend/src/api/Games.ts | 16 | ||||
| -rw-r--r-- | frontend/src/api/Maps.ts | 158 | ||||
| -rw-r--r-- | frontend/src/api/Mod.ts | 98 | ||||
| -rw-r--r-- | frontend/src/api/User.ts | 18 |
6 files changed, 260 insertions, 122 deletions
diff --git a/frontend/src/api/Api.ts b/frontend/src/api/Api.ts index 862e688..b782d17 100644 --- a/frontend/src/api/Api.ts +++ b/frontend/src/api/Api.ts | |||
| @@ -1,18 +1,39 @@ | |||
| 1 | import { MapDiscussionCommentContent, MapDiscussionContent, ModMenuContent } from '@customTypes/Content'; | 1 | import { MapDiscussionContent, ModMenuContent } from "@customTypes/Content"; |
| 2 | import { delete_token, get_token } from '@api/Auth'; | 2 | import { delete_token, get_token } from "@api/Auth"; |
| 3 | import { get_user, get_profile, post_profile } from '@api/User'; | 3 | import { get_user, get_profile, post_profile } from "@api/User"; |
| 4 | import { get_games, get_chapters, get_games_chapters, get_game_maps, get_search } from '@api/Games'; | 4 | import { |
| 5 | import { get_official_rankings, get_unofficial_rankings } from '@api/Rankings'; | 5 | get_games, |
| 6 | import { get_map_summary, get_map_leaderboard, get_map_discussions, get_map_discussion, post_map_discussion, post_map_discussion_comment, delete_map_discussion, post_record, delete_map_record } from '@api/Maps'; | 6 | get_chapters, |
| 7 | import { delete_map_summary, post_map_summary, put_map_image, put_map_summary } from '@api/Mod'; | 7 | get_games_chapters, |
| 8 | import { UploadRunContent } from '@customTypes/Content'; | 8 | get_game_maps, |
| 9 | get_search, | ||
| 10 | } from "@api/Games"; | ||
| 11 | import { get_official_rankings, get_unofficial_rankings } from "@api/Rankings"; | ||
| 12 | import { | ||
| 13 | get_map_summary, | ||
| 14 | get_map_leaderboard, | ||
| 15 | get_map_discussions, | ||
| 16 | get_map_discussion, | ||
| 17 | post_map_discussion, | ||
| 18 | post_map_discussion_comment, | ||
| 19 | delete_map_discussion, | ||
| 20 | post_record, | ||
| 21 | delete_map_record, | ||
| 22 | } from "@api/Maps"; | ||
| 23 | import { | ||
| 24 | delete_map_summary, | ||
| 25 | post_map_summary, | ||
| 26 | put_map_image, | ||
| 27 | put_map_summary, | ||
| 28 | } from "@api/Mod"; | ||
| 29 | import { UploadRunContent } from "@customTypes/Content"; | ||
| 9 | 30 | ||
| 10 | // add new api call function entries here | 31 | // add new api call function entries here |
| 11 | // example usage: API.get_games(); | 32 | // example usage: API.get_games(); |
| 12 | export const API = { | 33 | export const API = { |
| 13 | // Auth | 34 | // Auth |
| 14 | get_token: () => get_token(), | 35 | get_token: () => get_token(), |
| 15 | 36 | ||
| 16 | delete_token: () => delete_token(), | 37 | delete_token: () => delete_token(), |
| 17 | // User | 38 | // User |
| 18 | get_user: (user_id: string) => get_user(user_id), | 39 | get_user: (user_id: string) => get_user(user_id), |
| @@ -29,28 +50,49 @@ export const API = { | |||
| 29 | get_unofficial_rankings: () => get_unofficial_rankings(), | 50 | get_unofficial_rankings: () => get_unofficial_rankings(), |
| 30 | // Maps | 51 | // Maps |
| 31 | get_map_summary: (map_id: string) => get_map_summary(map_id), | 52 | get_map_summary: (map_id: string) => get_map_summary(map_id), |
| 32 | get_map_leaderboard: (map_id: string, page: string) => get_map_leaderboard(map_id, page), | 53 | get_map_leaderboard: (map_id: string, page: string) => |
| 54 | get_map_leaderboard(map_id, page), | ||
| 33 | get_map_discussions: (map_id: string) => get_map_discussions(map_id), | 55 | get_map_discussions: (map_id: string) => get_map_discussions(map_id), |
| 34 | get_map_discussion: (map_id: string, discussion_id: number) => get_map_discussion(map_id, discussion_id), | 56 | get_map_discussion: (map_id: string, discussion_id: number) => |
| 57 | get_map_discussion(map_id, discussion_id), | ||
| 35 | 58 | ||
| 36 | post_map_discussion: (token: string, map_id: string, content: MapDiscussionContent) => post_map_discussion(token, map_id, content), | 59 | post_map_discussion: ( |
| 37 | post_map_discussion_comment: (token: string, map_id: string, discussion_id: number, comment: string) => post_map_discussion_comment(token, map_id, discussion_id, comment), | 60 | token: string, |
| 38 | post_record: (token: string, run: UploadRunContent, map_id: number) => post_record(token, run, map_id), | 61 | map_id: string, |
| 62 | content: MapDiscussionContent | ||
| 63 | ) => post_map_discussion(token, map_id, content), | ||
| 64 | post_map_discussion_comment: ( | ||
| 65 | token: string, | ||
| 66 | map_id: string, | ||
| 67 | discussion_id: number, | ||
| 68 | comment: string | ||
| 69 | ) => post_map_discussion_comment(token, map_id, discussion_id, comment), | ||
| 70 | post_record: (token: string, run: UploadRunContent, map_id: number) => | ||
| 71 | post_record(token, run, map_id), | ||
| 39 | 72 | ||
| 40 | delete_map_discussion: (token: string, map_id: string, discussion_id: number) => delete_map_discussion(token, map_id, discussion_id), | 73 | delete_map_discussion: ( |
| 74 | token: string, | ||
| 75 | map_id: string, | ||
| 76 | discussion_id: number | ||
| 77 | ) => delete_map_discussion(token, map_id, discussion_id), | ||
| 41 | 78 | ||
| 42 | delete_map_record: (token: string, map_id: number, record_id: number) => delete_map_record(token, map_id, record_id), | 79 | delete_map_record: (token: string, map_id: number, record_id: number) => |
| 80 | delete_map_record(token, map_id, record_id), | ||
| 43 | // Mod | 81 | // Mod |
| 44 | post_map_summary: (token: string, map_id: string, content: ModMenuContent) => post_map_summary(token, map_id, content), | 82 | post_map_summary: (token: string, map_id: string, content: ModMenuContent) => |
| 45 | 83 | post_map_summary(token, map_id, content), | |
| 46 | put_map_image: (token: string, map_id: string, image: string) => put_map_image(token, map_id, image), | 84 | |
| 47 | put_map_summary: (token: string, map_id: string, content: ModMenuContent) => put_map_summary(token, map_id, content), | 85 | put_map_image: (token: string, map_id: string, image: string) => |
| 48 | 86 | put_map_image(token, map_id, image), | |
| 49 | delete_map_summary: (token: string, map_id: string, route_id: number) => delete_map_summary(token, map_id, route_id), | 87 | put_map_summary: (token: string, map_id: string, content: ModMenuContent) => |
| 88 | put_map_summary(token, map_id, content), | ||
| 89 | |||
| 90 | delete_map_summary: (token: string, map_id: string, route_id: number) => | ||
| 91 | delete_map_summary(token, map_id, route_id), | ||
| 50 | }; | 92 | }; |
| 51 | 93 | ||
| 52 | const BASE_API_URL: string = "/api/v1/" | 94 | const BASE_API_URL: string = "https://lp.portal2.sr/api/v1/" |
| 53 | 95 | ||
| 54 | export function url(path: string): string { | 96 | export function url(path: string): string { |
| 55 | return BASE_API_URL + path; | 97 | return BASE_API_URL + path; |
| 56 | }; | 98 | } |
diff --git a/frontend/src/api/Auth.ts b/frontend/src/api/Auth.ts index 875c7e5..98c6d36 100644 --- a/frontend/src/api/Auth.ts +++ b/frontend/src/api/Auth.ts | |||
| @@ -2,7 +2,7 @@ import axios from "axios"; | |||
| 2 | import { url } from "@api/Api"; | 2 | import { url } from "@api/Api"; |
| 3 | 3 | ||
| 4 | export const get_token = async (): Promise<string | undefined> => { | 4 | export const get_token = async (): Promise<string | undefined> => { |
| 5 | const response = await axios.get(url(`token`)) | 5 | const response = await axios.get(url(`token`)); |
| 6 | if (!response.data.success) { | 6 | if (!response.data.success) { |
| 7 | return undefined; | 7 | return undefined; |
| 8 | } | 8 | } |
diff --git a/frontend/src/api/Games.ts b/frontend/src/api/Games.ts index 72bb4b3..b739f80 100644 --- a/frontend/src/api/Games.ts +++ b/frontend/src/api/Games.ts | |||
| @@ -6,26 +6,30 @@ import { Map } from "@customTypes/Map"; | |||
| 6 | import { Search } from "@customTypes/Search"; | 6 | import { Search } from "@customTypes/Search"; |
| 7 | 7 | ||
| 8 | export const get_games = async (): Promise<Game[]> => { | 8 | export const get_games = async (): Promise<Game[]> => { |
| 9 | const response = await axios.get(url(`games`)) | 9 | const response = await axios.get(url(`games`)); |
| 10 | return response.data.data; | 10 | return response.data.data; |
| 11 | }; | 11 | }; |
| 12 | 12 | ||
| 13 | export const get_chapters = async (chapter_id: string): Promise<GameChapter> => { | 13 | export const get_chapters = async ( |
| 14 | chapter_id: string | ||
| 15 | ): Promise<GameChapter> => { | ||
| 14 | const response = await axios.get(url(`chapters/${chapter_id}`)); | 16 | const response = await axios.get(url(`chapters/${chapter_id}`)); |
| 15 | return response.data.data; | 17 | return response.data.data; |
| 16 | } | 18 | }; |
| 17 | 19 | ||
| 18 | export const get_games_chapters = async (game_id: string): Promise<GamesChapters> => { | 20 | export const get_games_chapters = async ( |
| 21 | game_id: string | ||
| 22 | ): Promise<GamesChapters> => { | ||
| 19 | const response = await axios.get(url(`games/${game_id}`)); | 23 | const response = await axios.get(url(`games/${game_id}`)); |
| 20 | return response.data.data; | 24 | return response.data.data; |
| 21 | }; | 25 | }; |
| 22 | 26 | ||
| 23 | export const get_game_maps = async (game_id: string): Promise<Map[]> => { | 27 | export const get_game_maps = async (game_id: string): Promise<Map[]> => { |
| 24 | const response = await axios.get(url(`games/${game_id}/maps`)) | 28 | const response = await axios.get(url(`games/${game_id}/maps`)); |
| 25 | return response.data.data.maps; | 29 | return response.data.data.maps; |
| 26 | }; | 30 | }; |
| 27 | 31 | ||
| 28 | export const get_search = async (q: string): Promise<Search> => { | 32 | export const get_search = async (q: string): Promise<Search> => { |
| 29 | const response = await axios.get(url(`search?q=${q}`)) | 33 | const response = await axios.get(url(`search?q=${q}`)); |
| 30 | return response.data.data; | 34 | return response.data.data; |
| 31 | }; | 35 | }; |
diff --git a/frontend/src/api/Maps.ts b/frontend/src/api/Maps.ts index aa967ce..2485941 100644 --- a/frontend/src/api/Maps.ts +++ b/frontend/src/api/Maps.ts | |||
| @@ -1,15 +1,25 @@ | |||
| 1 | import axios from "axios"; | 1 | import axios from "axios"; |
| 2 | import { url } from "@api/Api"; | 2 | import { url } from "@api/Api"; |
| 3 | import { MapDiscussionContent, UploadRunContent } from "@customTypes/Content"; | 3 | import { MapDiscussionContent, UploadRunContent } from "@customTypes/Content"; |
| 4 | import { MapSummary, MapLeaderboard, MapDiscussions, MapDiscussion } from "@customTypes/Map"; | 4 | import { |
| 5 | MapSummary, | ||
| 6 | MapLeaderboard, | ||
| 7 | MapDiscussions, | ||
| 8 | MapDiscussion, | ||
| 9 | } from "@customTypes/Map"; | ||
| 5 | 10 | ||
| 6 | export const get_map_summary = async (map_id: string): Promise<MapSummary> => { | 11 | export const get_map_summary = async (map_id: string): Promise<MapSummary> => { |
| 7 | const response = await axios.get(url(`maps/${map_id}/summary`)) | 12 | const response = await axios.get(url(`maps/${map_id}/summary`)); |
| 8 | return response.data.data; | 13 | return response.data.data; |
| 9 | }; | 14 | }; |
| 10 | 15 | ||
| 11 | export const get_map_leaderboard = async (map_id: string, page: string): Promise<MapLeaderboard | undefined> => { | 16 | export const get_map_leaderboard = async ( |
| 12 | const response = await axios.get(url(`maps/${map_id}/leaderboards?page=${page}`)); | 17 | map_id: string, |
| 18 | page: string | ||
| 19 | ): Promise<MapLeaderboard | undefined> => { | ||
| 20 | const response = await axios.get( | ||
| 21 | url(`maps/${map_id}/leaderboards?page=${page}`) | ||
| 22 | ); | ||
| 13 | if (!response.data.success) { | 23 | if (!response.data.success) { |
| 14 | return undefined; | 24 | return undefined; |
| 15 | } | 25 | } |
| @@ -17,15 +27,17 @@ export const get_map_leaderboard = async (map_id: string, page: string): Promise | |||
| 17 | // map the kind of leaderboard | 27 | // map the kind of leaderboard |
| 18 | data.records = data.records.map((record: any) => { | 28 | data.records = data.records.map((record: any) => { |
| 19 | if (record.host && record.partner) { | 29 | if (record.host && record.partner) { |
| 20 | return { ...record, kind: 'multiplayer' }; | 30 | return { ...record, kind: "multiplayer" }; |
| 21 | } else { | 31 | } else { |
| 22 | return { ...record, kind: 'singleplayer' }; | 32 | return { ...record, kind: "singleplayer" }; |
| 23 | } | 33 | } |
| 24 | }); | 34 | }); |
| 25 | return data; | 35 | return data; |
| 26 | }; | 36 | }; |
| 27 | 37 | ||
| 28 | export const get_map_discussions = async (map_id: string): Promise<MapDiscussions | undefined> => { | 38 | export const get_map_discussions = async ( |
| 39 | map_id: string | ||
| 40 | ): Promise<MapDiscussions | undefined> => { | ||
| 29 | const response = await axios.get(url(`maps/${map_id}/discussions`)); | 41 | const response = await axios.get(url(`maps/${map_id}/discussions`)); |
| 30 | if (!response.data.data.discussions) { | 42 | if (!response.data.data.discussions) { |
| 31 | return undefined; | 43 | return undefined; |
| @@ -33,74 +45,122 @@ export const get_map_discussions = async (map_id: string): Promise<MapDiscussion | |||
| 33 | return response.data.data; | 45 | return response.data.data; |
| 34 | }; | 46 | }; |
| 35 | 47 | ||
| 36 | export const get_map_discussion = async (map_id: string, discussion_id: number): Promise<MapDiscussion | undefined> => { | 48 | export const get_map_discussion = async ( |
| 37 | const response = await axios.get(url(`maps/${map_id}/discussions/${discussion_id}`)); | 49 | map_id: string, |
| 50 | discussion_id: number | ||
| 51 | ): Promise<MapDiscussion | undefined> => { | ||
| 52 | const response = await axios.get( | ||
| 53 | url(`maps/${map_id}/discussions/${discussion_id}`) | ||
| 54 | ); | ||
| 38 | if (!response.data.data.discussion) { | 55 | if (!response.data.data.discussion) { |
| 39 | return undefined; | 56 | return undefined; |
| 40 | } | 57 | } |
| 41 | return response.data.data; | 58 | return response.data.data; |
| 42 | }; | 59 | }; |
| 43 | 60 | ||
| 44 | export const post_map_discussion = async (token: string, map_id: string, content: MapDiscussionContent): Promise<boolean> => { | 61 | export const post_map_discussion = async ( |
| 45 | const response = await axios.post(url(`maps/${map_id}/discussions`), { | 62 | token: string, |
| 46 | "title": content.title, | 63 | map_id: string, |
| 47 | "content": content.content, | 64 | content: MapDiscussionContent |
| 48 | }, { | 65 | ): Promise<boolean> => { |
| 49 | headers: { | 66 | const response = await axios.post( |
| 50 | "Authorization": token, | 67 | url(`maps/${map_id}/discussions`), |
| 68 | { | ||
| 69 | title: content.title, | ||
| 70 | content: content.content, | ||
| 71 | }, | ||
| 72 | { | ||
| 73 | headers: { | ||
| 74 | Authorization: token, | ||
| 75 | }, | ||
| 51 | } | 76 | } |
| 52 | }); | 77 | ); |
| 53 | return response.data.success; | 78 | return response.data.success; |
| 54 | }; | 79 | }; |
| 55 | 80 | ||
| 56 | export const post_map_discussion_comment = async (token: string, map_id: string, discussion_id: number, comment: string): Promise<boolean> => { | 81 | export const post_map_discussion_comment = async ( |
| 57 | const response = await axios.post(url(`maps/${map_id}/discussions/${discussion_id}`), { | 82 | token: string, |
| 58 | "comment": comment, | 83 | map_id: string, |
| 59 | }, { | 84 | discussion_id: number, |
| 60 | headers: { | 85 | comment: string |
| 61 | "Authorization": token, | 86 | ): Promise<boolean> => { |
| 87 | const response = await axios.post( | ||
| 88 | url(`maps/${map_id}/discussions/${discussion_id}`), | ||
| 89 | { | ||
| 90 | comment: comment, | ||
| 91 | }, | ||
| 92 | { | ||
| 93 | headers: { | ||
| 94 | Authorization: token, | ||
| 95 | }, | ||
| 62 | } | 96 | } |
| 63 | }); | 97 | ); |
| 64 | return response.data.success; | 98 | return response.data.success; |
| 65 | }; | 99 | }; |
| 66 | 100 | ||
| 67 | export const delete_map_discussion = async (token: string, map_id: string, discussion_id: number): Promise<boolean> => { | 101 | export const delete_map_discussion = async ( |
| 68 | const response = await axios.delete(url(`maps/${map_id}/discussions/${discussion_id}`), { | 102 | token: string, |
| 69 | headers: { | 103 | map_id: string, |
| 70 | "Authorization": token, | 104 | discussion_id: number |
| 105 | ): Promise<boolean> => { | ||
| 106 | const response = await axios.delete( | ||
| 107 | url(`maps/${map_id}/discussions/${discussion_id}`), | ||
| 108 | { | ||
| 109 | headers: { | ||
| 110 | Authorization: token, | ||
| 111 | }, | ||
| 71 | } | 112 | } |
| 72 | }); | 113 | ); |
| 73 | return response.data.success; | 114 | return response.data.success; |
| 74 | }; | 115 | }; |
| 75 | 116 | ||
| 76 | export const post_record = async (token: string, run: UploadRunContent, map_id: number): Promise<[boolean, string]> => { | 117 | export const post_record = async ( |
| 118 | token: string, | ||
| 119 | run: UploadRunContent, | ||
| 120 | map_id: number | ||
| 121 | ): Promise<[boolean, string]> => { | ||
| 77 | if (run.partner_demo) { | 122 | if (run.partner_demo) { |
| 78 | const response = await axios.postForm(url(`maps/${map_id}/record`), { | 123 | const response = await axios.postForm( |
| 79 | "host_demo": run.host_demo, | 124 | url(`maps/${map_id}/record`), |
| 80 | "partner_demo": run.partner_demo, | 125 | { |
| 81 | }, { | 126 | host_demo: run.host_demo, |
| 82 | headers: { | 127 | partner_demo: run.partner_demo, |
| 83 | "Authorization": token, | 128 | }, |
| 129 | { | ||
| 130 | headers: { | ||
| 131 | Authorization: token, | ||
| 132 | }, | ||
| 84 | } | 133 | } |
| 85 | }); | 134 | ); |
| 86 | return [response.data.success, response.data.message]; | 135 | return [response.data.success, response.data.message]; |
| 87 | } else { | 136 | } else { |
| 88 | const response = await axios.postForm(url(`maps/${map_id}/record`), { | 137 | const response = await axios.postForm( |
| 89 | "host_demo": run.host_demo, | 138 | url(`maps/${map_id}/record`), |
| 90 | }, { | 139 | { |
| 91 | headers: { | 140 | host_demo: run.host_demo, |
| 92 | "Authorization": token, | 141 | }, |
| 142 | { | ||
| 143 | headers: { | ||
| 144 | Authorization: token, | ||
| 145 | }, | ||
| 93 | } | 146 | } |
| 94 | }); | 147 | ); |
| 95 | return [response.data.success, response.data.message]; | 148 | return [response.data.success, response.data.message]; |
| 96 | } | 149 | } |
| 97 | } | 150 | }; |
| 98 | 151 | ||
| 99 | export const delete_map_record = async (token: string, map_id: number, record_id: number): Promise<boolean> => { | 152 | export const delete_map_record = async ( |
| 100 | const response = await axios.delete(url(`maps/${map_id}/record/${record_id}`), { | 153 | token: string, |
| 101 | headers: { | 154 | map_id: number, |
| 102 | "Authorization": token, | 155 | record_id: number |
| 156 | ): Promise<boolean> => { | ||
| 157 | const response = await axios.delete( | ||
| 158 | url(`maps/${map_id}/record/${record_id}`), | ||
| 159 | { | ||
| 160 | headers: { | ||
| 161 | Authorization: token, | ||
| 162 | }, | ||
| 103 | } | 163 | } |
| 104 | }); | 164 | ); |
| 105 | return response.data.success; | 165 | return response.data.success; |
| 106 | }; | 166 | }; |
diff --git a/frontend/src/api/Mod.ts b/frontend/src/api/Mod.ts index 1511f8b..d682f1a 100644 --- a/frontend/src/api/Mod.ts +++ b/frontend/src/api/Mod.ts | |||
| @@ -2,57 +2,85 @@ 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 | }; |
diff --git a/frontend/src/api/User.ts b/frontend/src/api/User.ts index 88da0f2..004aa22 100644 --- a/frontend/src/api/User.ts +++ b/frontend/src/api/User.ts | |||
| @@ -10,16 +10,20 @@ export const get_user = async (user_id: string): Promise<UserProfile> => { | |||
| 10 | export const get_profile = async (token: string): Promise<UserProfile> => { | 10 | export const get_profile = async (token: string): Promise<UserProfile> => { |
| 11 | const response = await axios.get(url(`profile`), { | 11 | const response = await axios.get(url(`profile`), { |
| 12 | headers: { | 12 | headers: { |
| 13 | "Authorization": token, | 13 | Authorization: token, |
| 14 | } | 14 | }, |
| 15 | }); | 15 | }); |
| 16 | return response.data.data; | 16 | return response.data.data; |
| 17 | }; | 17 | }; |
| 18 | 18 | ||
| 19 | export const post_profile = async (token: string) => { | 19 | export const post_profile = async (token: string): Promise<void> => { |
| 20 | const _ = await axios.post(url(`profile`), {}, { | 20 | await axios.post( |
| 21 | headers: { | 21 | url(`profile`), |
| 22 | "Authorization": token, | 22 | {}, |
| 23 | { | ||
| 24 | headers: { | ||
| 25 | Authorization: token, | ||
| 26 | }, | ||
| 23 | } | 27 | } |
| 24 | }); | 28 | ); |
| 25 | }; | 29 | }; |