]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/tournament/Detail.js
application admin UI
[alttp.git] / resources / js / components / tournament / Detail.js
index 3ce0b48998987405626aa82bf5de8244f63ab28f..cdc9b601bd3b3c81448b1e3015e57b312f3922bc 100644 (file)
@@ -3,33 +3,91 @@ import React from 'react';
 import { Button, Col, Container, Row } from 'react-bootstrap';
 import { withTranslation } from 'react-i18next';
 
+import ApplyButton from './ApplyButton';
 import Scoreboard from './Scoreboard';
+import ApplicationsButton from '../applications/Button';
 import Protocol from '../protocol/Protocol';
 import Rounds from '../rounds/List';
+import Box from '../users/Box';
 import {
+       isRunner,
        mayAddRounds,
        mayViewProtocol,
 } from '../../helpers/permissions';
+import {
+       getTournamentAdmins,
+       getTournamentMonitors,
+       hasRunners,
+       hasTournamentAdmins,
+       hasTournamentMonitors,
+} from '../../helpers/Tournament';
 import { withUser } from '../../helpers/UserContext';
 import i18n from '../../i18n';
 
+const getClassName = (tournament, user) => {
+       const classNames = ['tournament'];
+       if (tournament.locked) {
+               classNames.push('is-locked');
+       } else {
+               classNames.push('is-active');
+       }
+       if (isRunner(user, tournament)) {
+               classNames.push('is-runner');
+       }
+       return classNames.join(' ');
+};
+
 const Detail = ({
        addRound,
        tournament,
        user,
-}) => <Container fluid>
+}) => <Container className={getClassName(tournament, user)} fluid>
        <Row>
                <Col lg={8} xl={9}>
                        <div className="d-flex align-items-center justify-content-between">
                                <h1>{tournament.title}</h1>
-                               {mayViewProtocol(user, tournament) ?
-                                       <Protocol id={tournament.id} />
-                               : null}
+                               <div className="button-bar">
+                                       <ApplicationsButton tournament={tournament} />
+                                       <ApplyButton tournament={tournament} />
+                                       {mayViewProtocol(user, tournament) ?
+                                               <Protocol id={tournament.id} />
+                                       : null}
+                               </div>
                        </div>
                </Col>
        </Row>
        <Row>
-               <Col lg={8} xl={9}>
+               <Col lg={{ order: 2, span: 4 }} xl={{ order: 2, span: 3 }}>
+                       <div className="tournament-sidebar">
+                               <div className="d-flex align-items-center justify-content-between">
+                                       <h2>{i18n.t('tournaments.scoreboard')}</h2>
+                               </div>
+                               {hasRunners(tournament) ?
+                                       <Scoreboard tournament={tournament} />
+                               : null}
+                               {hasTournamentAdmins(tournament) ?
+                                       <>
+                                               <div className="d-flex align-items-center justify-content-between">
+                                                       <h2>{i18n.t('tournaments.admins')}</h2>
+                                               </div>
+                                               {getTournamentAdmins(tournament).map(p =>
+                                                       <p key={p.id}><Box user={p.user} /></p>
+                                               )}
+                                       </>
+                               : null}
+                               {hasTournamentMonitors(tournament) ?
+                                       <>
+                                               <div className="d-flex align-items-center justify-content-between">
+                                                       <h2>{i18n.t('tournaments.monitors')}</h2>
+                                               </div>
+                                               {getTournamentMonitors(tournament).map(p =>
+                                                       <p key={p.id}><Box user={p.user} /></p>
+                                               )}
+                                       </>
+                               : null}
+                       </div>
+               </Col>
+               <Col lg={{ order: 1, span: 8 }} xl={{ order: 1, span: 9 }}>
                        <div className="d-flex align-items-center justify-content-between">
                                <h2>{i18n.t('rounds.heading')}</h2>
                                {addRound && mayAddRounds(user, tournament) ?
@@ -42,14 +100,6 @@ const Detail = ({
                                <Rounds rounds={tournament.rounds} tournament={tournament} />
                        : null}
                </Col>
-               <Col lg={4} xl={3}>
-                       <div className="d-flex align-items-center justify-content-between">
-                               <h2>{i18n.t('tournaments.scoreboard')}</h2>
-                       </div>
-                       {tournament.participants ?
-                               <Scoreboard tournament={tournament} />
-                       : null}
-               </Col>
        </Row>
 </Container>;