From a2c6981d3602b84a3094d5277bcbb6f9f4d11e14 Mon Sep 17 00:00:00 2001 From: rhpidfyre Date: Thu, 12 Dec 2024 13:18:12 -0500 Subject: [PATCH] web: proxy the dev port 3000 to 8081 for api calls --- web/next.config.ts | 10 +++++- .../[submissionId]/_reviewButtons.tsx | 21 +------------ web/src/app/ts/Submission.ts | 31 ++++++------------- 3 files changed, 20 insertions(+), 42 deletions(-) diff --git a/web/next.config.ts b/web/next.config.ts index 6f7f3fe..a6ad2a0 100644 --- a/web/next.config.ts +++ b/web/next.config.ts @@ -1,7 +1,15 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { - distDir: "build" + distDir: "build", + rewrites: async () => { + return [ + { + source: "/v1/submissions/1/status/:statustype", + destination: "http://localhost:8081/v1/submissions/:statustype" + } + ] + } }; export default nextConfig; diff --git a/web/src/app/submissions/[submissionId]/_reviewButtons.tsx b/web/src/app/submissions/[submissionId]/_reviewButtons.tsx index f5a3a14..e28d914 100644 --- a/web/src/app/submissions/[submissionId]/_reviewButtons.tsx +++ b/web/src/app/submissions/[submissionId]/_reviewButtons.tsx @@ -8,27 +8,8 @@ interface ReviewButton { color: ButtonOwnProps["color"] } -// CREATE: -// curl -H 'Content-Type: application/json' \ -// --cookie "session_id=123" \ -// -d '{"ID":0,"DisplayName":"Example Map","Creator":"Quaternions","GameID":1,"Date":"2024-12-09T20:43:49.957660142-08:00","Submitter":52250025,"AssetID":255299419,"AssetVersion":7,"Completed":true,"TargetAssetID":5692134283,"StatusID":0}' \ -// -X POST \ -// localhost:8081/v1/submissions - -// GET: -// curl -H 'Content-Type: application/json' \ -// --cookie "session_id=c5191ddc-eee1-4010-900c-6b2c7b6780ab" \ -// -X GET \ -// localhost:8081/v1/submissions/1 - -// SUBMIT: -// curl -H 'Content-Type: application/json' \ -// --cookie "session_id=c5191ddc-eee1-4010-900c-6b2c7b6780ab" \ -// -X POST \ -// localhost:8081/v1/submissions/1/status/submit - function ReviewButtonClicked(action: Action) { - const post = fetch(`http://localhost:8081/v1/submissions/1/status/${action}`, { + const post = fetch(`http://localhost:3000/v1/submissions/1/status/${action}`, { method: "POST", headers: { "Content-type": "application/json", diff --git a/web/src/app/ts/Submission.ts b/web/src/app/ts/Submission.ts index fbac5a7..b321b8f 100644 --- a/web/src/app/ts/Submission.ts +++ b/web/src/app/ts/Submission.ts @@ -25,39 +25,28 @@ interface SubmissionInfo { } function SubmissionStatusToString(submission_status: SubmissionStatus): string { - let Review: string switch (submission_status) { case SubmissionStatus.Published: - Review = "PUBLISHED" - break + return "PUBLISHED" case SubmissionStatus.Rejected: - Review = "REJECTED" - break + return "REJECTED" case SubmissionStatus.Publishing: - Review = "PUBLISHING" - break + return "PUBLISHING" case SubmissionStatus.Validated: - Review = "VALIDATED" - break + return "VALIDATED" case SubmissionStatus.Validating: - Review = "VALIDATING" - break + return "VALIDATING" case SubmissionStatus.Accepted: - Review = "ACCEPTED" - break + return "ACCEPTED" case SubmissionStatus.ChangesRequested: - Review = "CHANGES REQUESTED" - break + return "CHANGES REQUESTED" case SubmissionStatus.Submitted: - Review = "SUBMITTED" - break + return "SUBMITTED" case SubmissionStatus.UnderConstruction: - Review = "UNDER CONSTRUCTION" - break + return "UNDER CONSTRUCTION" default: - Review = "UNKNOWN" + return "UNKNOWN" } - return Review } export {