X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Frounds%2FSeedButton.js;h=59bc3baaa15b2d18a6fcb16b5c5e84bf2492fec3;hb=4c5a82cb876e96c72c50e8bc12bd8a43a9afe847;hp=1d68b6a833ca129caa9b481cf40182b8df488c46;hpb=a907ef7c6676fef11f42933b2d79bdd496b20122;p=alttp.git diff --git a/resources/js/components/rounds/SeedButton.js b/resources/js/components/rounds/SeedButton.js index 1d68b6a..59bc3ba 100644 --- a/resources/js/components/rounds/SeedButton.js +++ b/resources/js/components/rounds/SeedButton.js @@ -1,24 +1,36 @@ import PropTypes from 'prop-types'; import React, { useState } from 'react'; import { Button } from 'react-bootstrap'; -import { withTranslation } from 'react-i18next'; +import { useTranslation } from 'react-i18next'; import SeedDialog from './SeedDialog'; import { maySetSeed } from '../../helpers/permissions'; -import { withUser } from '../../helpers/UserContext'; -import i18n from '../../i18n'; +import { useUser } from '../../hooks/user'; -const SeedButton = ({ round, tournament, user }) => { +const SeedButton = ({ round, tournament }) => { const [showDialog, setShowDialog] = useState(false); + const { t } = useTranslation(); + const { user } = useUser(); + if (round.seed) { - return ( + return <> - ); + {round.spoiler ? + + : null} + ; } - if (maySetSeed(user, tournament)) { + if (maySetSeed(user, tournament, round)) { return <> setShowDialog(false)} @@ -26,21 +38,20 @@ const SeedButton = ({ round, tournament, user }) => { show={showDialog} /> ; } - return i18n.t('rounds.noSeed'); + return t('rounds.noSeed'); }; SeedButton.propTypes = { round: PropTypes.shape({ seed: PropTypes.string, + spoiler: PropTypes.string, }), tournament: PropTypes.shape({ }), - user: PropTypes.shape({ - }), }; -export default withTranslation()(withUser(SeedButton)); +export default SeedButton;