= [
+ {
+ title: "#",
+ dataIndex: "id",
+ render: (_, { id }) => (
+
+ {id}
+
+ ),
+ width: 50,
+ align: "center",
+ },
+ {
+ title: "Origem",
+ dataIndex: "origin",
+ render: (_, { origin }) => {origin},
+ responsive: ["sm"],
+ width: 200,
+ },
+ {
+ title: "Título",
+ dataIndex: "title",
+ render: (_, { title, status }) => (
+
+ {title}
+ {status !== "not submitted" ? (
+ {renderStatus(status)}
+ ) : null}
+
+ ),
+ width: 600,
+ },
+ {
+ title: "Resolvidos / tentados",
+ render: (_, { solvedCount, attemptedCount }) => {
+ const solvedProportion = attemptedCount
+ ? (100 * (solvedCount / attemptedCount)).toFixed(0)
+ : 0;
+ return (
+
+ {`${solvedCount} / ${attemptedCount} (${solvedProportion}%)`}
+
+ );
+ },
+ responsive: ["sm"],
+ width: 175,
+ },
+ ];
+
+ return (
+
+ bordered
+ rowKey={(record) => record.id}
+ columns={columns}
+ dataSource={problems}
+ pagination={{ hideOnSinglePage: true, defaultPageSize: 26 }}
+ />
+ );
+};
diff --git a/packages/app/pages/contest/[id].tsx b/packages/app/pages/contest/[id].tsx
index 45de79a..0158246 100644
--- a/packages/app/pages/contest/[id].tsx
+++ b/packages/app/pages/contest/[id].tsx
@@ -1,13 +1,9 @@
-import { CheckCircleFilled, CloseCircleFilled } from "@ant-design/icons";
import { Card, Tabs } from "antd";
-import Table, { ColumnsType } from "antd/lib/table";
import { GetServerSideProps, InferGetServerSidePropsType } from "next";
import { HTMLAttributes } from "react";
import classNames from "classnames";
-import { Hyperlink } from "../../components/Hyperlink";
import { ContestHeader } from "../../components/ContestHeader";
-
-type ProblemStatus = "not submitted" | "accepted" | "rejected";
+import { ContestProblems } from "../../components/ContestProblems";
const { TabPane } = Tabs;
@@ -132,79 +128,6 @@ export const getServerSideProps: GetServerSideProps = async ()
},
});
-interface ContestProblemsProps {
- problems: ProblemOverview[];
-}
-
-const renderStatus = (status: ProblemStatus) => {
- if (status === "accepted") {
- return ;
- }
- if (status === "rejected") {
- return ;
- }
- return null;
-};
-
-const ContestProblems = ({ problems }: ContestProblemsProps) => {
- const columns: ColumnsType = [
- {
- title: "#",
- dataIndex: "id",
- render: (_, { id }) => (
-
- {id}
-
- ),
- width: 50,
- align: "center",
- },
- {
- title: "Origem",
- dataIndex: "origin",
- render: (_, { origin }) => {origin},
- responsive: ["sm"],
- width: 200,
- },
- {
- title: "Título",
- dataIndex: "title",
- render: (_, { title, status }) => (
-
- {title}
- {renderStatus(status)}
-
- ),
- width: 600,
- },
- {
- title: "Resolvidos / tentados",
- render: (_, { solvedCount, attemptedCount }) => {
- const solvedProportion = attemptedCount
- ? (100 * (solvedCount / attemptedCount)).toFixed(0)
- : 0;
- return (
-
- {`${solvedCount} / ${attemptedCount} (${solvedProportion}%)`}
-
- );
- },
- responsive: ["sm"],
- width: 175,
- },
- ];
-
- return (
-
- bordered
- rowKey={(record) => record.id}
- columns={columns}
- dataSource={problems}
- pagination={{ hideOnSinglePage: true, defaultPageSize: 26 }}
- />
- );
-};
-
type ContestBodyProps = Pick &
HTMLAttributes;
diff --git a/packages/app/typings/global.d.ts b/packages/app/typings/global.d.ts
index bacfaa1..7d4e480 100644
--- a/packages/app/typings/global.d.ts
+++ b/packages/app/typings/global.d.ts
@@ -1,3 +1,5 @@
+declare type ProblemStatus = "not submitted" | "accepted" | "rejected";
+
declare interface ProblemOverview {
id: string;
origin: string;