Skip to content

Commit

Permalink
fix: sync submissions with api changes
Browse files Browse the repository at this point in the history
  • Loading branch information
amrsalama committed Oct 25, 2021
1 parent 7a853fb commit 9eb676b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 40 deletions.
3 changes: 2 additions & 1 deletion src/Components/Board/Board.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ class Board extends React.Component {
</div>
<div className="sheets-section">
<div className="sheets">
{sheets.map(({ id, name, problems }, sheetIndex) => (
{sheets.map(({ id, groupId, name, problems }, sheetIndex) => (
<div className="sheet-collection" key={sheetIndex}>
<Sheet
id={id}
groupId={groupId}
name={name}
problems={problems}
traineesCount={traineesCount}
Expand Down
45 changes: 10 additions & 35 deletions src/Components/BoardCell/BoardCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,27 @@ import styles from './styles';

class BoardCell extends React.Component {
render() {
const { sheetId, submission, ignored, right, bottom, firstColumn, firstRow } = this.props;
const { verdict, triesBeforeAC, list } = submission;
const { submission, ignored, firstColumn, firstRow } = this.props;
const { isAc, triesBeforeAc } = submission;
const isSolved = isAc !== undefined;

return (
<>
<div
className={cn('board-cell', {
'first-column': firstColumn,
'first-row': firstRow,
ac: verdict === 'AC',
'not-ac': verdict !== 'AC',
'not-solved': verdict === undefined,
ac: isAc,
'not-ac': !isAc,
'not-solved': !isSolved,
ignored,
})}
style={{ width: blockSize, height: blockSize }}
>
{verdict !== undefined ? (
{isSolved ? (
<>
<div>{verdict}</div>
<div className="tries-before-ac">{triesBeforeAC ? `+${triesBeforeAC}` : ''}</div>
<div
className="list"
style={{
[right ? 'right' : 'left']: blockSize / 2 - 15,
[bottom ? 'bottom' : 'top']: blockSize / 2 + 15,
}}
>
{list.map(({ id: submissionId, message, verdict: submissionVerdict }, submissionIndex) => (
<a
key={submissionIndex}
className="list-item"
href={`https://codeforces.com/group/MWSDmqGsZm/contest/${sheetId}/submission/${submissionId}`}
rel="noopener noreferrer"
target="_blank"
>
<div
className={cn('state', {
ac: submissionVerdict === 'AC',
'not-ac': submissionVerdict !== 'AC',
})}
></div>
<div>{submissionId}</div>
<div>{message}</div>
</a>
))}
</div>
<div>{isAc ? 'AC' : ''}</div>
<div className="tries-before-ac">{triesBeforeAc ? `+${triesBeforeAc}` : ''}</div>
</>
) : (
<div>?</div>
Expand All @@ -64,7 +39,7 @@ class BoardCell extends React.Component {
}

BoardCell.propTypes = {
sheetId: PropTypes.string.isRequired,
sheetId: PropTypes.number.isRequired,
submission: PropTypes.object.isRequired,
ignored: PropTypes.bool.isRequired,
right: PropTypes.bool.isRequired,
Expand Down
9 changes: 5 additions & 4 deletions src/Components/Sheet/Sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import styles from './styles';

class Sheet extends React.Component {
render() {
const { id, name, problems, traineesCount, hovered, hoveredProblemIndex, onSheetHover, onProblemHover } =
const { id, groupId, name, problems, traineesCount, hovered, hoveredProblemIndex, onSheetHover, onProblemHover } =
this.props;

return (
<>
<div className="sheet">
<a
href={`https://codeforces.com/group/MWSDmqGsZm/contest/${id}`}
href={`https://codeforces.com/group/${groupId}/contest/${id}`}
rel="noopener noreferrer"
target="_blank"
className={cn('title', { hovered })}
Expand All @@ -27,7 +27,7 @@ class Sheet extends React.Component {
{problems.map((problem, index) => (
<a
key={index}
href={`https://codeforces.com/group/MWSDmqGsZm/contest/${id}/problem/${problem.id}`}
href={`https://codeforces.com/group/${groupId}/contest/${id}/problem/${problem.id}`}
rel="noopener noreferrer"
target="_blank"
className={cn('problem', {
Expand Down Expand Up @@ -67,7 +67,8 @@ class Sheet extends React.Component {
}

Sheet.propTypes = {
id: PropTypes.string.isRequired,
id: PropTypes.number.isRequired,
groupId: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
problems: PropTypes.arrayOf(
PropTypes.shape({
Expand Down

0 comments on commit 9eb676b

Please sign in to comment.