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;
return <>
<Button
onClick={() => setShowDialog(true)}
- title={i18n.t('tournaments.applications')}
+ title={t('tournaments.applications')}
variant="primary"
>
<Icon.APPLICATIONS title="" />
accept_applications: PropTypes.bool,
id: PropTypes.number,
}),
- user: PropTypes.shape({
- }),
};
-export default withTranslation()(withUser(ApplicationsButton));
+export default ApplicationsButton;