aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-12 01:34:20 +0900
committernsfisis <nsfisis@gmail.com>2024-08-12 01:48:08 +0900
commitb97b245861b93a5ab5f8bde095d9920fabd0cbbd (patch)
treefcb88fe6a71747623cbe7f9b5c3042818ab519cd
parent5964fa404909550a2dd42a75633fef223fdb05fb (diff)
downloadiosdc-japan-2024-albatross-b97b245861b93a5ab5f8bde095d9920fabd0cbbd.tar.gz
iosdc-japan-2024-albatross-b97b245861b93a5ab5f8bde095d9920fabd0cbbd.tar.zst
iosdc-japan-2024-albatross-b97b245861b93a5ab5f8bde095d9920fabd0cbbd.zip
refactor(frontend): move some types to app/models
-rw-r--r--frontend/app/components/ExecStatusIndicatorIcon.tsx3
-rw-r--r--frontend/app/components/GolfWatchApp.client.tsx5
-rw-r--r--frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx61
-rw-r--r--frontend/app/models/PlayerInfo.ts9
-rw-r--r--frontend/app/models/SubmissionResult.ts38
-rw-r--r--frontend/app/models/VerificationResult.ts17
6 files changed, 70 insertions, 63 deletions
diff --git a/frontend/app/components/ExecStatusIndicatorIcon.tsx b/frontend/app/components/ExecStatusIndicatorIcon.tsx
index a76e957..c5b37f8 100644
--- a/frontend/app/components/ExecStatusIndicatorIcon.tsx
+++ b/frontend/app/components/ExecStatusIndicatorIcon.tsx
@@ -5,9 +5,10 @@ import {
faRotate,
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { VerificationResultStatus } from "../models/VerificationResult";
type Props = {
- status: string;
+ status: VerificationResultStatus;
};
export default function ExecStatusIndicatorIcon({ status }: Props) {
diff --git a/frontend/app/components/GolfWatchApp.client.tsx b/frontend/app/components/GolfWatchApp.client.tsx
index 1da2066..3f97d2a 100644
--- a/frontend/app/components/GolfWatchApp.client.tsx
+++ b/frontend/app/components/GolfWatchApp.client.tsx
@@ -1,11 +1,10 @@
import { useEffect, useState } from "react";
import type { components } from "../.server/api/schema";
import useWebSocket, { ReadyState } from "../hooks/useWebSocket";
+import type { PlayerInfo } from "../models/PlayerInfo";
import GolfWatchAppConnecting from "./GolfWatchApps/GolfWatchAppConnecting";
import GolfWatchAppFinished from "./GolfWatchApps/GolfWatchAppFinished";
-import GolfWatchAppGaming, {
- PlayerInfo,
-} from "./GolfWatchApps/GolfWatchAppGaming";
+import GolfWatchAppGaming from "./GolfWatchApps/GolfWatchAppGaming";
import GolfWatchAppStarting from "./GolfWatchApps/GolfWatchAppStarting";
import GolfWatchAppWaiting from "./GolfWatchApps/GolfWatchAppWaiting";
diff --git a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx
index 173e8e3..5ca778b 100644
--- a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx
+++ b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx
@@ -1,3 +1,5 @@
+import { PlayerInfo } from "../../models/PlayerInfo";
+import { submissionResultStatusToLabel } from "../../models/SubmissionResult";
import ExecStatusIndicatorIcon from "../ExecStatusIndicatorIcon";
type Props = {
@@ -7,65 +9,6 @@ type Props = {
leftTimeSeconds: number;
};
-export type PlayerInfo = {
- displayName: string | null;
- iconPath: string | null;
- score: number | null;
- code: string | null;
- submissionResult?: SubmissionResult;
-};
-
-type SubmissionResult = {
- status:
- | "running"
- | "success"
- | "wrong_answer"
- | "timeout"
- | "compile_error"
- | "runtime_error"
- | "internal_error";
- verificationResults: VerificationResult[];
-};
-
-type VerificationResult = {
- testcase_id: number | null;
- status:
- | "running"
- | "success"
- | "wrong_answer"
- | "timeout"
- | "compile_error"
- | "runtime_error"
- | "internal_error"
- | "canceled";
- label: string;
- stdout: string;
- stderr: string;
-};
-
-function submissionResultStatusToLabel(
- status: SubmissionResult["status"] | 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";
- }
-}
-
export default function GolfWatchAppGaming({
problem,
playerInfoA,
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;
+};