From eae19bb1b047b3568e7a9a624b50e80886e56331 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:47:50 +0300 Subject: feat/frontend: optimizing imports, file extensions (#230) Co-authored-by: FifthWit --- frontend/src/api/Maps.tsx | 106 ---------------------------------------------- 1 file changed, 106 deletions(-) delete mode 100644 frontend/src/api/Maps.tsx (limited to 'frontend/src/api/Maps.tsx') diff --git a/frontend/src/api/Maps.tsx b/frontend/src/api/Maps.tsx deleted file mode 100644 index fc50293..0000000 --- a/frontend/src/api/Maps.tsx +++ /dev/null @@ -1,106 +0,0 @@ -import axios from "axios"; -import { url } from "./Api"; -import { MapDiscussionContent, UploadRunContent } from "../types/Content"; -import { MapSummary, MapLeaderboard, MapDiscussions, MapDiscussion } from "../types/Map"; - -export const get_map_summary = async (map_id: string): Promise => { - const response = await axios.get(url(`maps/${map_id}/summary`)) - return response.data.data; -}; - -export const get_map_leaderboard = async (map_id: string): Promise => { - const response = await axios.get(url(`maps/${map_id}/leaderboards`)); - if (!response.data.success) { - return undefined; - } - const data = response.data.data; - // map the kind of leaderboard - data.records = data.records.map((record: any) => { - if (record.host && record.partner) { - return { ...record, kind: 'multiplayer' }; - } else { - return { ...record, kind: 'singleplayer' }; - } - }); - return data; -}; - -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; - } - return response.data.data; -}; - -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, - } - }); - 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, - } - }); - 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, - } - }); - return response.data.success; -}; - -export const post_record = async (token: string, run: UploadRunContent): Promise<[boolean, string]> => { - if (run.partner_demo) { - const response = await axios.postForm(url(`maps/${run.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/${run.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, - } - }); - return response.data.success; -}; -- cgit v1.2.3