From 92447e02e5fc3977c9cfbca7a8de4132cbb4f13b Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Wed, 16 Oct 2024 21:13:54 +0300 Subject: refactor: upload run logic improvement --- frontend/src/api/Maps.tsx | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'frontend/src/api/Maps.tsx') diff --git a/frontend/src/api/Maps.tsx b/frontend/src/api/Maps.tsx index fbad78c..6bdc3e6 100644 --- a/frontend/src/api/Maps.tsx +++ b/frontend/src/api/Maps.tsx @@ -1,6 +1,6 @@ import axios from "axios"; import { url } from "./Api"; -import { MapDiscussionContent } from "../types/Content"; +import { MapDiscussionContent, UploadRunContent } from "../types/Content"; import { MapSummary, MapLeaderboard, MapDiscussions, MapDiscussion } from "../types/Map"; export const get_map_summary = async (map_id: string): Promise => { @@ -74,3 +74,27 @@ export const delete_map_discussion = async (token: string, map_id: string, discu }); return response.data.success; }; + +export const post_record = async (token: string, run: UploadRunContent): Promise<[string]> => { + if (run.partner_demo && run.partner_id) { + const response = await axios.postForm(url(`maps/${run.map_id}/record`), { + "host_demo": run.host_demo, + "partner_demo": run.partner_demo, + "partner_id": run.partner_id, + }, { + headers: { + "Authorization": token, + } + }); + return 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.message; + } +}; -- cgit v1.2.3