1 import PropTypes from 'prop-types';
2 import React from 'react';
3 import { withTranslation } from 'react-i18next';
5 import LockButton from './LockButton';
6 import SeedButton from './SeedButton';
7 import SeedCode from './SeedCode';
8 import SeedRolledBy from './SeedRolledBy';
9 import List from '../results/List';
10 import ReportButton from '../results/ReportButton';
11 import { isRunner } from '../../helpers/permissions';
12 import { isComplete } from '../../helpers/Round';
13 import { findParticipant } from '../../helpers/Tournament';
14 import { hasFinishedRound } from '../../helpers/User';
15 import { withUser } from '../../helpers/UserContext';
16 import i18n from '../../i18n';
18 const getClassName = (round, tournament, user) => {
19 const classNames = ['round', 'd-flex'];
21 classNames.push('is-locked');
23 classNames.push('is-unlocked');
25 if (isComplete(tournament, round)) {
26 classNames.push('is-complete');
28 classNames.push('is-incomplete');
30 if (hasFinishedRound(user, round)) {
31 classNames.push('has-finished');
32 } else if (isRunner(user, tournament)) {
33 classNames.push('has-not-finished');
35 return classNames.join(' ');
43 <li className={getClassName(round, tournament, user)}>
44 <div className="info">
46 {round.number ? `#${round.number} ` : '#?'}
47 {i18n.t('rounds.date', { date: new Date(round.created_at) })}
52 <SeedCode code={round.code} />
58 tournament={tournament}
61 <SeedRolledBy round={round} />
63 {isRunner(user, tournament) ?
64 <p className="report">
66 participant={findParticipant(tournament, user)}
68 tournament={tournament}
72 <LockButton round={round} tournament={tournament} />
74 <List round={round} tournament={tournament} />
78 round: PropTypes.shape({
79 code: PropTypes.arrayOf(PropTypes.string),
80 created_at: PropTypes.string,
81 locked: PropTypes.bool,
82 number: PropTypes.number,
83 seed: PropTypes.string,
85 tournament: PropTypes.shape({
86 participants: PropTypes.arrayOf(PropTypes.shape({
89 user: PropTypes.shape({
93 export default withTranslation()(withUser(Item));