X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=inline;f=resources%2Fjs%2Fcomponents%2Ftournament%2FDetail.js;h=84592f6beb1a525a5f2886cf6661600ad2c975ec;hb=4c5a82cb876e96c72c50e8bc12bd8a43a9afe847;hp=60c9d245716439653296fea58decc6659f4b8ae8;hpb=edd0e97bfdc544114f30bf4c13a929631c44a555;p=alttp.git diff --git a/resources/js/components/tournament/Detail.js b/resources/js/components/tournament/Detail.js index 60c9d24..84592f6 100644 --- a/resources/js/components/tournament/Detail.js +++ b/resources/js/components/tournament/Detail.js @@ -1,52 +1,133 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { Button, Container } from 'react-bootstrap'; -import { withTranslation } from 'react-i18next'; +import { Button, Col, Container, Row } from 'react-bootstrap'; +import { useTranslation } from 'react-i18next'; -import Participants from '../participants/List'; +import ApplyButton from './ApplyButton'; +import Scoreboard from './Scoreboard'; +import ScoreChartButton from './ScoreChartButton'; +import SettingsButton from './SettingsButton'; +import ApplicationsButton from '../applications/Button'; +import Protocol from '../protocol/Protocol'; import Rounds from '../rounds/List'; -import { mayAddRounds } from '../../helpers/permissions'; -import { withUser } from '../../helpers/UserContext'; -import i18n from '../../i18n'; +import Box from '../users/Box'; +import { + isRunner, + mayAddRounds, + mayUpdateTournament, + mayViewProtocol, +} from '../../helpers/permissions'; +import { + getTournamentAdmins, + getTournamentMonitors, + hasRunners, + hasScoreboard, + hasTournamentAdmins, + hasTournamentMonitors, +} from '../../helpers/Tournament'; +import { useUser } from '../../hooks/user'; + +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, -}) => -
-

{tournament.title}

-
-
-

{i18n.t('participants.heading')}

-
- {tournament.participants ? - - : null} -
-

{i18n.t('rounds.heading')}

- {addRound && mayAddRounds(user, tournament) ? - - : null} -
- {tournament.rounds ? - - : null} -
; +}) => { + const { t } = useTranslation(); + const { user } = useUser(); + + return + + +
+

{tournament.title}

+
+ + + {mayUpdateTournament(user, tournament) ? + + : null} + {mayViewProtocol(user, tournament) ? + + : null} +
+
+ +
+ + +
+ {hasScoreboard(tournament) ? <> +
+

{t('tournaments.scoreboard')}

+ {hasRunners(tournament) && tournament.rounds.length > 2 ? + + : null} +
+ {hasRunners(tournament) ? + + : null} + : null} + {hasTournamentAdmins(tournament) ? + <> +
+

{t('tournaments.admins')}

+
+ {getTournamentAdmins(tournament).map(p => +

+ )} + + : null} + {hasTournamentMonitors(tournament) ? + <> +
+

{t('tournaments.monitors')}

+
+ {getTournamentMonitors(tournament).map(p => +

+ )} + + : null} +
+ + +
+

{t('rounds.heading')}

+ {addRound && mayAddRounds(user, tournament) ? + + : null} +
+ {tournament.rounds ? + + : null} + +
+
; +}; Detail.propTypes = { addRound: PropTypes.func, tournament: PropTypes.shape({ + id: PropTypes.number, participants: PropTypes.arrayOf(PropTypes.shape({ })), rounds: PropTypes.arrayOf(PropTypes.shape({ })), title: PropTypes.string, }), - user: PropTypes.shape({ - }), }; -export default withTranslation()(withUser(Detail)); +export default Detail;