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 ApplyButton from './ApplyButton';
7 import Scoreboard from './Scoreboard';
8 import ApplicationsButton from '../applications/Button';
9 import Protocol from '../protocol/Protocol';
10 import Rounds from '../rounds/List';
11 import Box from '../users/Box';
16 } from '../../helpers/permissions';
19 getTournamentMonitors,
22 hasTournamentMonitors,
23 } from '../../helpers/Tournament';
24 import { withUser } from '../../helpers/UserContext';
25 import i18n from '../../i18n';
27 const getClassName = (tournament, user) => {
28 const classNames = ['tournament'];
29 if (tournament.locked) {
30 classNames.push('is-locked');
32 classNames.push('is-active');
34 if (isRunner(user, tournament)) {
35 classNames.push('is-runner');
37 return classNames.join(' ');
44 }) => <Container className={getClassName(tournament, user)} fluid>
47 <div className="d-flex align-items-center justify-content-between">
48 <h1>{tournament.title}</h1>
49 <div className="button-bar">
50 <ApplicationsButton tournament={tournament} />
51 <ApplyButton tournament={tournament} />
52 {mayViewProtocol(user, tournament) ?
53 <Protocol id={tournament.id} />
60 <Col lg={{ order: 2, span: 4 }} xl={{ order: 2, span: 3 }}>
61 <div className="tournament-sidebar">
62 <div className="d-flex align-items-center justify-content-between">
63 <h2>{i18n.t('tournaments.scoreboard')}</h2>
65 {hasRunners(tournament) ?
66 <Scoreboard tournament={tournament} />
68 {hasTournamentAdmins(tournament) ?
70 <div className="d-flex align-items-center justify-content-between">
71 <h2>{i18n.t('tournaments.admins')}</h2>
73 {getTournamentAdmins(tournament).map(p =>
74 <p key={p.id}><Box user={p.user} /></p>
78 {hasTournamentMonitors(tournament) ?
80 <div className="d-flex align-items-center justify-content-between">
81 <h2>{i18n.t('tournaments.monitors')}</h2>
83 {getTournamentMonitors(tournament).map(p =>
84 <p key={p.id}><Box user={p.user} /></p>
90 <Col lg={{ order: 1, span: 8 }} xl={{ order: 1, span: 9 }}>
91 <div className="d-flex align-items-center justify-content-between">
92 <h2>{i18n.t('rounds.heading')}</h2>
93 {addRound && mayAddRounds(user, tournament) ?
94 <Button onClick={addRound}>
95 {i18n.t('rounds.new')}
100 <Rounds rounds={tournament.rounds} tournament={tournament} />
107 addRound: PropTypes.func,
108 tournament: PropTypes.shape({
109 id: PropTypes.number,
110 participants: PropTypes.arrayOf(PropTypes.shape({
112 rounds: PropTypes.arrayOf(PropTypes.shape({
114 title: PropTypes.string,
116 user: PropTypes.shape({
120 export default withTranslation()(withUser(Detail));