From b97b245861b93a5ab5f8bde095d9920fabd0cbbd Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 12 Aug 2024 01:34:20 +0900 Subject: refactor(frontend): move some types to app/models --- frontend/app/models/PlayerInfo.ts | 9 ++++++++ frontend/app/models/SubmissionResult.ts | 38 +++++++++++++++++++++++++++++++ frontend/app/models/VerificationResult.ts | 17 ++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 frontend/app/models/PlayerInfo.ts create mode 100644 frontend/app/models/SubmissionResult.ts create mode 100644 frontend/app/models/VerificationResult.ts (limited to 'frontend/app/models') diff --git a/frontend/app/models/PlayerInfo.ts b/frontend/app/models/PlayerInfo.ts new file mode 100644 index 0000000..7206a8b --- /dev/null +++ b/frontend/app/models/PlayerInfo.ts @@ -0,0 +1,9 @@ +import type { SubmissionResult } from "./SubmissionResult"; + +export type PlayerInfo = { + displayName: string | null; + iconPath: string | null; + score: number | null; + code: string | null; + submissionResult?: SubmissionResult; +}; diff --git a/frontend/app/models/SubmissionResult.ts b/frontend/app/models/SubmissionResult.ts new file mode 100644 index 0000000..7311494 --- /dev/null +++ b/frontend/app/models/SubmissionResult.ts @@ -0,0 +1,38 @@ +import type { VerificationResult } from "./VerificationResult"; + +export type SubmissionResultStatus = + | "running" + | "success" + | "wrong_answer" + | "timeout" + | "compile_error" + | "runtime_error" + | "internal_error"; + +export type SubmissionResult = { + status: SubmissionResultStatus; + verificationResults: VerificationResult[]; +}; + +export function submissionResultStatusToLabel( + status: SubmissionResultStatus | null, +) { + switch (status) { + case null: + return "-"; + case "running": + return "Running..."; + case "success": + return "Accepted"; + case "wrong_answer": + return "Wrong Answer"; + case "timeout": + return "Time Limit Exceeded"; + case "compile_error": + return "Compile Error"; + case "runtime_error": + return "Runtime Error"; + case "internal_error": + return "Internal Error"; + } +} diff --git a/frontend/app/models/VerificationResult.ts b/frontend/app/models/VerificationResult.ts new file mode 100644 index 0000000..09a7ef4 --- /dev/null +++ b/frontend/app/models/VerificationResult.ts @@ -0,0 +1,17 @@ +export type VerificationResultStatus = + | "running" + | "success" + | "wrong_answer" + | "timeout" + | "compile_error" + | "runtime_error" + | "internal_error" + | "canceled"; + +export type VerificationResult = { + testcase_id: number | null; + status: VerificationResultStatus; + label: string; + stdout: string; + stderr: string; +}; -- cgit v1.2.3-70-g09d2