diff --git a/.prettierignore b/.prettierignore index 711d77f..ede7d21 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,4 +3,5 @@ node_modules/ /pnpm-lock.yaml /postcss.config.cjs -src/components/Languages.tsx +src/components/Languages.ts +src/components/Verdict.ts diff --git a/src/components/Languages.tsx b/src/components/Languages.ts similarity index 100% rename from src/components/Languages.tsx rename to src/components/Languages.ts diff --git a/src/components/Verdict.ts b/src/components/Verdict.ts new file mode 100644 index 0000000..809d5e9 --- /dev/null +++ b/src/components/Verdict.ts @@ -0,0 +1,17 @@ +import { Verdict } from "../app/services/status"; + +/* eslint-disable prettier/prettier */ +export const VerdictMap: { + [key in Verdict]: { color: string; label: string; name: string }; +} = { + [Verdict.Accepted]: { color: "#52C41A", label: "AC", name: "Accepted" }, + [Verdict.WrongAnswer]: { color: "#E74C3C", label: "WA", name: "Wrong Answer" }, + [Verdict.JuryFailed]: { color: "#0E1D69", label: "JF", name: "Jury Failed" }, + [Verdict.PartialCorrect]: { color: "#E67E22", label: "PC", name: "Partial Correct" }, + [Verdict.TimeLimitExceeded]: { color: "#052242", label: "TLE", name: "Time Limit Exceeded" }, + [Verdict.MemoryLimitExceeded]: { color: "#052242", label: "MLE", name: "Memory Limit Exceeded" }, + [Verdict.RuntimeError]: { color: "#9D3DCF", label: "RE", name: "Runtime Error" }, + [Verdict.CompileError]: { color: "#FADB14", label: "CE", name: "Compile Error" }, + [Verdict.SystemError]: { color: "#0E1D69", label: "UKE", name: "System Error" }, +}; +/* eslint-enable prettier/prettier */ diff --git a/src/pages/StatusPage.tsx b/src/pages/StatusPage.tsx new file mode 100644 index 0000000..d19c48c --- /dev/null +++ b/src/pages/StatusPage.tsx @@ -0,0 +1,150 @@ +import type React from "react"; +import { lazy } from "react"; +import { useParams } from "react-router-dom"; +import { + Accordion, + AccordionItem, + AccordionPanel, + Alert, + AlertIcon, + Box, + Spinner, + Stack, + Tab, + TabList, + TabPanel, + TabPanels, + Tabs, + Text, + Tooltip, + Wrap, + WrapItem, +} from "@chakra-ui/react"; + +import { useStatusQuery } from "../app/services/status"; +import { useDetailQuery } from "../app/services/problem"; +import { LanguageMap } from "../components/Languages"; +import { VerdictMap } from "../components/Verdict"; + +const ProblemInfoMenu = lazy(() => import("../components/ProblemInfoMenu")); +const TitleItem = lazy(() => import("../components/AccordionTitleItem")); +const Highlight = lazy(() => import("../components/Highlight")); + +const gridStyle: React.CSSProperties = { + width: "5.3em", + height: "5.3em", + margin: "0.2em", + fontSize: "1.5em", + padding: "0.5em", + textAlign: "center", + textShadow: "1px 1px 2px gray", + color: "white", +}; + +const topLeftStyle: React.CSSProperties = { + position: "absolute", + fontSize: "0.7em", +}; + +const labelStyle: React.CSSProperties = { + fontSize: "1.2em", + paddingTop: "0.6em", + textAlign: "center", +}; + +const statusStyle: React.CSSProperties = { + fontSize: "0.65em", + textAlign: "center", +}; + +export default function StatusPage() { + const { id } = useParams(); + const sid = Number(id) || 0; + const { data: status } = useStatusQuery({ sid: sid }); + const { data: problem } = useDetailQuery({ pid: status?.body.submission.problem.meta.ID || 0 }); + + const showSourceCode = status && status.body.submission.code !== ""; + const showMessage = status && (status.body.context.message !== "" || status.body.context.compile_message !== ""); + + const emptyTab = ( + + + + + Waiting for Judge... + + Please refresh the page after a few seconds. + + ); + + const statusCardTab = ( + + {status?.body.context.tasks.map((task) => ( + + + +
{`#${task.id}`}
+
+
{VerdictMap[task.verdict].label}
+
+ {`${Math.max( + task.runtime.real_time, + task.runtime.cpu_time, + )}ms/${task.runtime.memory}KB`} +
+
+
+
+
+ ))} +
+ ); + + const sourceCodeTab = ( + + ); + + const messageTab = ( + + + + + + + + + + + + + + + ); + + return ( + <> + + + + + Task Info + Source Code + Message + + + {status ? statusCardTab : emptyTab} + {sourceCodeTab} + {messageTab} + + + + + + + + + ); +} diff --git a/src/routes.tsx b/src/routes.tsx index 5642233..fbeb0a9 100644 --- a/src/routes.tsx +++ b/src/routes.tsx @@ -12,6 +12,7 @@ const ProblemListPage = lazy(() => import("./pages/ProblemListPage")); const ProblemDetailPage = lazy(() => import("./pages/ProblemDetailPage")); const SubmitPage = lazy(() => import("./pages/SubmitPage")); const SubmissionListPage = lazy(() => import("./pages/SubmissionListPage")); +const StatusPage = lazy(() => import("./pages/StatusPage")); export const router: RouteObject[] = [ { @@ -59,6 +60,14 @@ export const router: RouteObject[] = [ ), }, + { + path: "status/:id", + element: ( + + + + ), + }, ], }, ];