]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/tournament/ApplyButton.js
improved user context
[alttp.git] / resources / js / components / tournament / ApplyButton.js
index a6bde2f7ac5e622e4321d6056c83f0f4802aab9d..8bbd98ec12556daf57572178e50781c615896a84 100644 (file)
@@ -7,7 +7,7 @@ import toastr from 'toastr';
 
 import Icon from '../common/Icon';
 import { isApplicant, isDeniedApplicant, isRunner, mayApply } from '../../helpers/permissions';
-import { withUser } from '../../helpers/UserContext';
+import { useUser } from '../../hooks/user';
 import i18n from '../../i18n';
 
 const apply = async tournament => {
@@ -29,7 +29,9 @@ const getTitle = (user, tournament) => {
        return i18n.t('tournaments.apply');
 };
 
-const ApplyButton = ({ tournament, user }) => {
+const ApplyButton = ({ tournament }) => {
+       const { user } = useUser();
+
        if (!user || !tournament.accept_applications || isRunner(user, tournament)) return null;
 
        return <span className="d-inline-block" title={getTitle(user, tournament)}>
@@ -48,8 +50,6 @@ ApplyButton.propTypes = {
                accept_applications: PropTypes.bool,
                id: PropTypes.number,
        }),
-       user: PropTypes.shape({
-       }),
 };
 
-export default withTranslation()(withUser(ApplyButton));
+export default withTranslation()(ApplyButton);