From e40f07211f5f15dcb138e2520a76d13afd3c0cfd Mon Sep 17 00:00:00 2001 From: FifthWit Date: Thu, 30 Jan 2025 10:44:30 -0600 Subject: formatted with prettier --- frontend/src/api/Maps.ts | 160 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 110 insertions(+), 50 deletions(-) (limited to 'frontend/src/api/Maps.ts') diff --git a/frontend/src/api/Maps.ts b/frontend/src/api/Maps.ts index aa967ce..3a22f88 100644 --- a/frontend/src/api/Maps.ts +++ b/frontend/src/api/Maps.ts @@ -1,15 +1,25 @@ -import axios from "axios"; -import { url } from "@api/Api"; -import { MapDiscussionContent, UploadRunContent } from "@customTypes/Content"; -import { MapSummary, MapLeaderboard, MapDiscussions, MapDiscussion } from "@customTypes/Map"; +import axios from 'axios'; +import { url } from '@api/Api'; +import { MapDiscussionContent, UploadRunContent } from '@customTypes/Content'; +import { + MapSummary, + MapLeaderboard, + MapDiscussions, + MapDiscussion, +} from '@customTypes/Map'; export const get_map_summary = async (map_id: string): Promise => { - const response = await axios.get(url(`maps/${map_id}/summary`)) + const response = await axios.get(url(`maps/${map_id}/summary`)); return response.data.data; }; -export const get_map_leaderboard = async (map_id: string, page: string): Promise => { - const response = await axios.get(url(`maps/${map_id}/leaderboards?page=${page}`)); +export const get_map_leaderboard = async ( + map_id: string, + page: string +): Promise => { + const response = await axios.get( + url(`maps/${map_id}/leaderboards?page=${page}`) + ); if (!response.data.success) { return undefined; } @@ -25,7 +35,9 @@ export const get_map_leaderboard = async (map_id: string, page: string): Promise return data; }; -export const get_map_discussions = async (map_id: string): Promise => { +export const get_map_discussions = async ( + map_id: string +): Promise => { const response = await axios.get(url(`maps/${map_id}/discussions`)); if (!response.data.data.discussions) { return undefined; @@ -33,74 +45,122 @@ export const get_map_discussions = async (map_id: string): Promise => { - const response = await axios.get(url(`maps/${map_id}/discussions/${discussion_id}`)); +export const get_map_discussion = async ( + map_id: string, + discussion_id: number +): Promise => { + const response = await axios.get( + url(`maps/${map_id}/discussions/${discussion_id}`) + ); if (!response.data.data.discussion) { return undefined; } return response.data.data; }; -export const post_map_discussion = async (token: string, map_id: string, content: MapDiscussionContent): Promise => { - const response = await axios.post(url(`maps/${map_id}/discussions`), { - "title": content.title, - "content": content.content, - }, { - headers: { - "Authorization": token, +export const post_map_discussion = async ( + token: string, + map_id: string, + content: MapDiscussionContent +): Promise => { + const response = await axios.post( + url(`maps/${map_id}/discussions`), + { + title: content.title, + content: content.content, + }, + { + headers: { + Authorization: token, + }, } - }); + ); return response.data.success; }; -export const post_map_discussion_comment = async (token: string, map_id: string, discussion_id: number, comment: string): Promise => { - const response = await axios.post(url(`maps/${map_id}/discussions/${discussion_id}`), { - "comment": comment, - }, { - headers: { - "Authorization": token, +export const post_map_discussion_comment = async ( + token: string, + map_id: string, + discussion_id: number, + comment: string +): Promise => { + const response = await axios.post( + url(`maps/${map_id}/discussions/${discussion_id}`), + { + comment: comment, + }, + { + headers: { + Authorization: token, + }, } - }); + ); return response.data.success; }; -export const delete_map_discussion = async (token: string, map_id: string, discussion_id: number): Promise => { - const response = await axios.delete(url(`maps/${map_id}/discussions/${discussion_id}`), { - headers: { - "Authorization": token, +export const delete_map_discussion = async ( + token: string, + map_id: string, + discussion_id: number +): Promise => { + const response = await axios.delete( + url(`maps/${map_id}/discussions/${discussion_id}`), + { + headers: { + Authorization: token, + }, } - }); + ); return response.data.success; }; -export const post_record = async (token: string, run: UploadRunContent, map_id: number): Promise<[boolean, string]> => { +export const post_record = async ( + token: string, + run: UploadRunContent, + map_id: number +): Promise<[boolean, string]> => { if (run.partner_demo) { - const response = await axios.postForm(url(`maps/${map_id}/record`), { - "host_demo": run.host_demo, - "partner_demo": run.partner_demo, - }, { - headers: { - "Authorization": token, + const response = await axios.postForm( + url(`maps/${map_id}/record`), + { + host_demo: run.host_demo, + partner_demo: run.partner_demo, + }, + { + headers: { + Authorization: token, + }, } - }); + ); return [response.data.success, response.data.message]; } else { - const response = await axios.postForm(url(`maps/${map_id}/record`), { - "host_demo": run.host_demo, - }, { - headers: { - "Authorization": token, + const response = await axios.postForm( + url(`maps/${map_id}/record`), + { + host_demo: run.host_demo, + }, + { + headers: { + Authorization: token, + }, } - }); + ); return [response.data.success, response.data.message]; } -} +}; -export const delete_map_record = async (token: string, map_id: number, record_id: number): Promise => { - const response = await axios.delete(url(`maps/${map_id}/record/${record_id}`), { - headers: { - "Authorization": token, +export const delete_map_record = async ( + token: string, + map_id: number, + record_id: number +): Promise => { + const response = await axios.delete( + url(`maps/${map_id}/record/${record_id}`), + { + headers: { + Authorization: token, + }, } - }); + ); return response.data.success; }; -- cgit v1.2.3