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 List from '../results/List';
9 import ReportButton from '../results/ReportButton';
10 import { isParticipant, isRunner } from '../../helpers/permissions';
11 import { isComplete } from '../../helpers/Round';
12 import { findParticipant } from '../../helpers/Tournament';
13 import { hasFinishedRound } from '../../helpers/User';
14 import { withUser } from '../../helpers/UserContext';
15 import i18n from '../../i18n';
17 const getClassName = (round, tournament, user) => {
18 const classNames = ['round', 'd-flex'];
20 classNames.push('is-locked');
22 classNames.push('is-unlocked');
24 if (isComplete(tournament, round)) {
25 classNames.push('is-complete');
27 classNames.push('is-incomplete');
29 if (hasFinishedRound(user, round)) {
30 classNames.push('has-finished');
31 } else if (isRunner(user, tournament)) {
32 classNames.push('has-not-finished');
34 return classNames.join(' ');
42 <li className={getClassName(round, tournament, user)}>
43 <div className="info">
45 {round.number ? `#${round.number} ` : '#?'}
46 {i18n.t('rounds.date', { date: new Date(round.created_at) })}
51 <SeedCode code={round.code} />
57 tournament={tournament}
60 {!round.locked && isParticipant(user, tournament) ?
61 <p className="report">
63 participant={findParticipant(tournament, user)}
65 tournament={tournament}
69 <LockButton round={round} tournament={tournament} />
71 <List round={round} tournament={tournament} />
75 round: PropTypes.shape({
76 code: PropTypes.arrayOf(PropTypes.string),
77 created_at: PropTypes.string,
78 locked: PropTypes.bool,
79 number: PropTypes.number,
80 seed: PropTypes.string,
82 tournament: PropTypes.shape({
83 participants: PropTypes.arrayOf(PropTypes.shape({
86 user: PropTypes.shape({
90 export default withTranslation()(withUser(Item));