X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Ftournament%2FDetail.js;h=84592f6beb1a525a5f2886cf6661600ad2c975ec;hb=4c5a82cb876e96c72c50e8bc12bd8a43a9afe847;hp=bb9b9284461ebe85ea7c4a818cb417c8c7df43f6;hpb=537b998e8059c56e3a20ee2a89d42c3bbfbb80b8;p=alttp.git diff --git a/resources/js/components/tournament/Detail.js b/resources/js/components/tournament/Detail.js index bb9b928..84592f6 100644 --- a/resources/js/components/tournament/Detail.js +++ b/resources/js/components/tournament/Detail.js @@ -1,7 +1,7 @@ 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'; @@ -25,8 +25,7 @@ import { 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']; @@ -44,76 +43,80 @@ const getClassName = (tournament, user) => { const Detail = ({ addRound, tournament, - user, -}) => - - -
-

{tournament.title}

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

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

- {hasRunners(tournament) && tournament.rounds.length > 2 ? - +}) => { + const { t } = useTranslation(); + const { user } = useUser(); + + return + + +
+

{tournament.title}

+
+ + + {mayUpdateTournament(user, tournament) ? + + : null} + {mayViewProtocol(user, tournament) ? + : null}
- {hasRunners(tournament) ? - - : null} - : null} - {hasTournamentAdmins(tournament) ? - <> -
-

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

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

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

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

+

{t('tournaments.scoreboard')}

+ {hasRunners(tournament) && tournament.rounds.length > 2 ? + + : null}
- {getTournamentMonitors(tournament).map(p => -

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

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

- {addRound && mayAddRounds(user, tournament) ? - + {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} -
- {tournament.rounds ? - - : null} - - -; + + + ; +}; Detail.propTypes = { addRound: PropTypes.func, @@ -125,8 +128,6 @@ Detail.propTypes = { })), title: PropTypes.string, }), - user: PropTypes.shape({ - }), }; -export default withTranslation()(withUser(Detail)); +export default Detail;