]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/applications/Button.js
improved user context
[alttp.git] / resources / js / components / applications / Button.js
index 415042b6da6c58d0a5b7d46ee3b8577745188645..2361b09107b00a081aa1b5484e9d9d41866d03af 100644 (file)
@@ -1,17 +1,19 @@
 import PropTypes from 'prop-types';
-import React, { useState } from 'react';
+import React from 'react';
 import { Badge, Button } from 'react-bootstrap';
-import { withTranslation } from 'react-i18next';
+import { useTranslation } from 'react-i18next';
 
 import Dialog from './Dialog';
 import Icon from '../common/Icon';
 import { mayHandleApplications } from '../../helpers/permissions';
 import { getPendingApplications } from '../../helpers/Tournament';
-import { withUser } from '../../helpers/UserContext';
-import i18n from '../../i18n';
+import { useUser } from '../../hooks/user';
 
-const ApplicationsButton = ({ tournament, user }) => {
-       const [showDialog, setShowDialog] = useState(false);
+const ApplicationsButton = ({ tournament }) => {
+       const [showDialog, setShowDialog] = React.useState(false);
+
+       const { t } = useTranslation();
+       const { user } = useUser();
 
        if (!user || !tournament.accept_applications || !mayHandleApplications(user, tournament)) {
                return null;
@@ -22,7 +24,7 @@ const ApplicationsButton = ({ tournament, user }) => {
        return <>
                <Button
                        onClick={() => setShowDialog(true)}
-                       title={i18n.t('tournaments.applications')}
+                       title={t('tournaments.applications')}
                        variant="primary"
                >
                        <Icon.APPLICATIONS title="" />
@@ -46,8 +48,6 @@ ApplicationsButton.propTypes = {
                accept_applications: PropTypes.bool,
                id: PropTypes.number,
        }),
-       user: PropTypes.shape({
-       }),
 };
 
-export default withTranslation()(withUser(ApplicationsButton));
+export default ApplicationsButton;