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 ScoreChartButton from './ScoreChartButton';
9 import SettingsButton from './SettingsButton';
10 import ApplicationsButton from '../applications/Button';
11 import Protocol from '../protocol/Protocol';
12 import Rounds from '../rounds/List';
13 import Box from '../users/Box';
19 } from '../../helpers/permissions';
22 getTournamentMonitors,
25 hasTournamentMonitors,
26 } from '../../helpers/Tournament';
27 import { withUser } from '../../helpers/UserContext';
28 import i18n from '../../i18n';
30 const getClassName = (tournament, user) => {
31 const classNames = ['tournament'];
32 if (tournament.locked) {
33 classNames.push('is-locked');
35 classNames.push('is-active');
37 if (isRunner(user, tournament)) {
38 classNames.push('is-runner');
40 return classNames.join(' ');
47 }) => <Container className={getClassName(tournament, user)} fluid>
50 <div className="d-flex align-items-center justify-content-between">
51 <h1>{tournament.title}</h1>
52 <div className="button-bar">
53 <ApplicationsButton tournament={tournament} />
54 <ApplyButton tournament={tournament} />
55 {mayUpdateTournament(user, tournament) ?
56 <SettingsButton tournament={tournament} />
58 {mayViewProtocol(user, tournament) ?
59 <Protocol id={tournament.id} />
66 <Col lg={{ order: 2, span: 4 }} xl={{ order: 2, span: 3 }}>
67 <div className="tournament-sidebar">
68 <div className="d-flex align-items-center justify-content-between">
69 <h2>{i18n.t('tournaments.scoreboard')}</h2>
70 {hasRunners(tournament) && tournament.rounds.length > 2 ?
71 <ScoreChartButton tournament={tournament} />
74 {hasRunners(tournament) ?
75 <Scoreboard tournament={tournament} />
77 {hasTournamentAdmins(tournament) ?
79 <div className="d-flex align-items-center justify-content-between">
80 <h2>{i18n.t('tournaments.admins')}</h2>
82 {getTournamentAdmins(tournament).map(p =>
83 <p key={p.id}><Box user={p.user} /></p>
87 {hasTournamentMonitors(tournament) ?
89 <div className="d-flex align-items-center justify-content-between">
90 <h2>{i18n.t('tournaments.monitors')}</h2>
92 {getTournamentMonitors(tournament).map(p =>
93 <p key={p.id}><Box user={p.user} /></p>
99 <Col lg={{ order: 1, span: 8 }} xl={{ order: 1, span: 9 }}>
100 <div className="d-flex align-items-center justify-content-between">
101 <h2>{i18n.t('rounds.heading')}</h2>
102 {addRound && mayAddRounds(user, tournament) ?
103 <Button onClick={addRound}>
104 {i18n.t('rounds.new')}
109 <Rounds rounds={tournament.rounds} tournament={tournament} />
116 addRound: PropTypes.func,
117 tournament: PropTypes.shape({
118 id: PropTypes.number,
119 participants: PropTypes.arrayOf(PropTypes.shape({
121 rounds: PropTypes.arrayOf(PropTypes.shape({
123 title: PropTypes.string,
125 user: PropTypes.shape({
129 export default withTranslation()(withUser(Detail));