]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/rounds/SeedButton.js
improved user context
[alttp.git] / resources / js / components / rounds / SeedButton.js
index 71299cc7b84c0036b30da90cc3422f7b477ad4df..59bc3baaa15b2d18a6fcb16b5c5e84bf2492fec3 100644 (file)
@@ -1,20 +1,22 @@
 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 <>
                        <Button href={round.seed} target="_blank" variant="primary">
-                               {i18n.t('rounds.seed')}
+                               {t('rounds.seed')}
                        </Button>
                        {round.spoiler ?
                                <Button
@@ -23,7 +25,7 @@ const SeedButton = ({ round, tournament, user }) => {
                                        target="_blank"
                                        variant="outline-primary"
                                >
-                                       {i18n.t('rounds.spoiler')}
+                                       {t('rounds.spoiler')}
                                </Button>
                        : null}
                </>;
@@ -36,11 +38,11 @@ const SeedButton = ({ round, tournament, user }) => {
                                show={showDialog}
                        />
                        <Button onClick={() => setShowDialog(true)} variant="outline-primary">
-                               {i18n.t('rounds.setSeed')}
+                               {t('rounds.setSeed')}
                        </Button>
                </>;
        }
-       return i18n.t('rounds.noSeed');
+       return t('rounds.noSeed');
 };
 
 SeedButton.propTypes = {
@@ -50,8 +52,6 @@ SeedButton.propTypes = {
        }),
        tournament: PropTypes.shape({
        }),
-       user: PropTypes.shape({
-       }),
 };
 
-export default withTranslation()(withUser(SeedButton));
+export default SeedButton;