X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Ftournament%2FDetail.js;h=318e67757d395fdc2dce9507dfe955d875e14802;hb=147c5f43c5d41fa18e82edb6651fe5a37c789353;hp=d4e23cdba4e0ca359a634d2fda2b73e896e595c1;hpb=e0616336a824a6d59c4b9d25ef4ed7fa26214cef;p=alttp.git diff --git a/resources/js/components/tournament/Detail.js b/resources/js/components/tournament/Detail.js index d4e23cd..318e677 100644 --- a/resources/js/components/tournament/Detail.js +++ b/resources/js/components/tournament/Detail.js @@ -1,11 +1,12 @@ import PropTypes from 'prop-types'; import React from 'react'; import { Button, Col, Container, Row } from 'react-bootstrap'; -import { withTranslation } from 'react-i18next'; +import { useTranslation } from 'react-i18next'; 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'; @@ -13,17 +14,18 @@ import Box from '../users/Box'; import { isRunner, mayAddRounds, + mayUpdateTournament, mayViewProtocol, } from '../../helpers/permissions'; import { getTournamentAdmins, getTournamentMonitors, hasRunners, + hasScoreboard, hasTournamentAdmins, hasTournamentMonitors, } from '../../helpers/Tournament'; -import { withUser } from '../../helpers/UserContext'; -import i18n from '../../i18n'; +import { useUser } from '../../hooks/user'; const getClassName = (tournament, user) => { const classNames = ['tournament']; @@ -40,75 +42,90 @@ const getClassName = (tournament, user) => { const Detail = ({ addRound, + moreRounds, tournament, - user, -}) => - - -
-

{tournament.title}

-
- - - {mayViewProtocol(user, tournament) ? - +}) => { + 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}
-
- - - - -
+ +
-

{i18n.t('tournaments.scoreboard')}

- {hasRunners(tournament) && tournament.rounds.length > 2 ? - +

{t('rounds.heading')}

+ {addRound && mayAddRounds(user, tournament) ? + : null}
- {hasRunners(tournament) ? - + {tournament.rounds ? + : null} - {hasTournamentAdmins(tournament) ? - <> -
-

{i18n.t('tournaments.admins')}

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

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

{i18n.t('tournaments.monitors')}

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

- )} - - : null} -
- - -
-

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

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