1 import PropTypes from 'prop-types';
2 import React from 'react';
3 import { Button, Col, Container, Row } from 'react-bootstrap';
4 import { withTranslation } from 'react-i18next';
6 import Scoreboard from './Scoreboard';
7 import Protocol from '../protocol/Protocol';
8 import Rounds from '../rounds/List';
9 import Box from '../users/Box';
14 } from '../../helpers/permissions';
19 } from '../../helpers/Tournament';
20 import { withUser } from '../../helpers/UserContext';
21 import i18n from '../../i18n';
23 const getClassName = (tournament, user) => {
24 const classNames = ['tournament'];
25 if (tournament.locked) {
26 classNames.push('is-locked');
28 classNames.push('is-active');
30 if (isRunner(user, tournament)) {
31 classNames.push('is-runner');
33 return classNames.join(' ');
40 }) => <Container className={getClassName(tournament, user)} fluid>
43 <div className="d-flex align-items-center justify-content-between">
44 <h1>{tournament.title}</h1>
45 {mayViewProtocol(user, tournament) ?
46 <Protocol id={tournament.id} />
52 <Col lg={{ order: 2, span: 4 }} xl={{ order: 2, span: 3 }}>
53 <div className="d-flex align-items-center justify-content-between">
54 <h2>{i18n.t('tournaments.scoreboard')}</h2>
56 {hasRunners(tournament) ?
57 <Scoreboard tournament={tournament} />
59 {hasTournamentAdmins(tournament) ?
61 <div className="d-flex align-items-center justify-content-between">
62 <h2>{i18n.t('tournaments.admins')}</h2>
64 {getTournamentAdmins(tournament).map(p =>
65 <p key={p.id}><Box user={p.user} /></p>
70 <Col lg={{ order: 1, span: 8 }} xl={{ order: 1, span: 9 }}>
71 <div className="d-flex align-items-center justify-content-between">
72 <h2>{i18n.t('rounds.heading')}</h2>
73 {addRound && mayAddRounds(user, tournament) ?
74 <Button onClick={addRound}>
75 {i18n.t('rounds.new')}
80 <Rounds rounds={tournament.rounds} tournament={tournament} />
87 addRound: PropTypes.func,
88 tournament: PropTypes.shape({
90 participants: PropTypes.arrayOf(PropTypes.shape({
92 rounds: PropTypes.arrayOf(PropTypes.shape({
94 title: PropTypes.string,
96 user: PropTypes.shape({
100 export default withTranslation()(withUser(Detail));