@@ -75,7 +75,7 @@ const ProblemSet: React.FC<{ listMode?: boolean }> = observer(({ listMode }) =>
const fetchAll = () =>
currentContest
? fetchProblems(currentContest.id).then((problems) =>
- problems.map((problem) => ({ ...problem, id: problem.shortName as string })),
+ problems.map((problem) => ({ ...problem, id: problem.shortName as string }))
)
: Promise.resolve([]);
@@ -155,7 +155,7 @@ const ProblemSet: React.FC<{ listMode?: boolean }> = observer(({ listMode }) =>
item={submission ?? ({} as Submission)}
onClose={() => setSubmission(undefined)}
onSubmit={async (submission) => {
- await sendSubmission(currentContest!.id, profile!.team.id, submission);
+ await sendSubmission(currentContest!.id, profile!.team!.id, submission);
setSubmission(undefined);
}}
/>
diff --git a/client/src/pages/shared/Scoreboard.tsx b/projects/client/src/pages/shared/Scoreboard.tsx
similarity index 69%
rename from client/src/pages/shared/Scoreboard.tsx
rename to projects/client/src/pages/shared/Scoreboard.tsx
index 973da59..5c531a8 100644
--- a/client/src/pages/shared/Scoreboard.tsx
+++ b/projects/client/src/pages/shared/Scoreboard.tsx
@@ -3,8 +3,8 @@ import classNames from 'classnames';
import { observer } from 'mobx-react';
import React, { useEffect, useState } from 'react';
import { formatRestTime, getRGBColorContrast } from '../../core/helpers';
+import { Contest } from '../../core/models';
import { rootStore } from '../../core/stores/RootStore';
-import { NoActiveContest } from './NoActiveContest';
import Tooltip from './tooltip/Tooltip';
type TeamProblemScore = {
@@ -24,14 +24,14 @@ type TeamStandingRow = {
problemsScores: TeamProblemScore[];
};
-type Props = { compact?: boolean; className?: string };
+type Props = { contest: Contest; compact?: boolean; className?: string };
-const Scoreboard: React.FC
= observer(({ compact, className }) => {
+const Scoreboard: React.FC = observer(({ contest, compact, className }) => {
const [standing, setStanding] = useState([]);
const {
profile,
isUserJury,
- publicStore: { currentContest, scoreCaches },
+ publicStore: { scoreCaches },
contestsStore: { refreshScoreboardCache },
} = rootStore;
@@ -68,7 +68,7 @@ const Scoreboard: React.FC = observer(({ compact, className }) => {
: Math.floor(
(submissions - 1) * 20 +
(new Date(solveTime).getTime() - new Date(contest.startTime || '').getTime()) /
- 60000,
+ 60000
);
if (correct) {
cache[team.id].solvedProblems++;
@@ -83,7 +83,7 @@ const Scoreboard: React.FC = observer(({ compact, className }) => {
(new Date(isUserJury ? restrictedSolveTime : solveTime).getTime() -
new Date(contest.startTime).getTime()) /
1000,
- false,
+ false
),
numberOfAttempts: isUserJury ? restrictedSubmissions : submissions,
});
@@ -95,83 +95,87 @@ const Scoreboard: React.FC = observer(({ compact, className }) => {
? a.totalScore === b.totalScore
? a.teamName.localeCompare(b.teamName)
: a.totalScore - b.totalScore
- : b.solvedProblems - a.solvedProblems,
+ : b.solvedProblems - a.solvedProblems
)
.map((row) => {
row.problemsScores.sort((a, b) => a.problemName.localeCompare(b.problemName));
return row;
- }),
+ })
);
}
}, [scoreCaches, isUserJury]);
return (
- {!currentContest ? (
-
- ) : (
-
- {!compact && (
-
- Scoreboard of {currentContest.name}
- {isUserJury && (
-
- refreshScoreboardCache(currentContest.id)}
- >
-
+
+ {!compact && (
+
+ Scoreboard of {contest.name}
+ {isUserJury && (
+
+ refreshScoreboardCache(contest.id)}
+ >
+
+
+
+ )}
+
+ )}
+
+
+
+
+
+ #
+ |
+
+
+ Team
-
- )}
-
- )}
-
-
-
-
-
- #
- |
-
-
- Team
-
- |
-
- =
- |
-
- Score
- |
- {currentContest.problems
- .slice()
- .sort((a, b) => a.shortName.localeCompare(b.shortName))
- .map((problem) => (
-
-
+
+ =
+ |
+
+ Score
+ |
+ {contest.problems
+ .slice()
+ .sort((a, b) => a.shortName.localeCompare(b.shortName))
+ .map((problem) => (
+
+
+ 0.5,
+ })}
+ style={{ backgroundColor: problem.color }}
>
- 0.5,
- })}
- style={{ backgroundColor: problem.color }}
- >
- {problem.shortName}
-
-
- |
- ))}
+ {problem.shortName}
+
+
+ |
+ ))}
+
+
+
+ {!standing.length ? (
+
+
+ No teams
+ |
-
-
- {standing.map(
+ ) : (
+ standing.map(
({ teamId, teamName, solvedProblems, totalScore, problemsScores }, index) => {
return (
- (!compact || teamId === profile?.team.id) && (
+ (!compact || teamId === profile?.team?.id) && (
@@ -215,7 +219,7 @@ const Scoreboard: React.FC = observer(({ compact, className }) => {
'bg-red-600': getScoreboardCellColor(problemScore) === 'red',
'bg-gray-100 dark:bg-gray-700':
getScoreboardCellColor(problemScore) === 'white',
- },
+ }
)}
>
{problemScore.numberOfAttempts ? (
@@ -235,13 +239,13 @@ const Scoreboard: React.FC = observer(({ compact, className }) => {
|
)
);
- },
- )}
-
-
-
+ }
+ )
+ )}
+
+ |
- )}
+
);
});
@@ -249,7 +253,7 @@ const Scoreboard: React.FC = observer(({ compact, className }) => {
export default Scoreboard;
function getScoreboardCellColor(
- problemScore: TeamProblemScore,
+ problemScore: TeamProblemScore
): 'white' | 'green-dark' | 'green' | 'yellow' | 'red' {
if (problemScore.firstToSolve) return 'green-dark';
if (problemScore.correct) return 'green';
diff --git a/client/src/pages/shared/Spinner.tsx b/projects/client/src/pages/shared/Spinner.tsx
similarity index 98%
rename from client/src/pages/shared/Spinner.tsx
rename to projects/client/src/pages/shared/Spinner.tsx
index 3a96411..b9a6eaa 100644
--- a/client/src/pages/shared/Spinner.tsx
+++ b/projects/client/src/pages/shared/Spinner.tsx
@@ -10,7 +10,7 @@ const Spinner: React.FC = ({ className, fullScreen }) => (
'flex items-center justify-center h-full w-full bg-white dark:bg-gray-800',
{
'h-screen': fullScreen,
- },
+ }
)}
>