1 import PropTypes from 'prop-types';
2 import React, { useState } from 'react';
3 import { Badge, Button } from 'react-bootstrap';
4 import { withTranslation } from 'react-i18next';
6 import Dialog from './Dialog';
7 import Icon from '../common/Icon';
8 import { mayHandleApplications } from '../../helpers/permissions';
9 import { getPendingApplications } from '../../helpers/Tournament';
10 import { withUser } from '../../helpers/UserContext';
11 import i18n from '../../i18n';
13 const ApplicationsButton = ({ tournament, user }) => {
14 const [showDialog, setShowDialog] = useState(false);
16 if (!user || !tournament.accept_applications || !mayHandleApplications(user, tournament)) {
20 const pending = getPendingApplications(tournament);
24 onClick={() => setShowDialog(true)}
25 title={i18n.t('tournaments.applications')}
28 <Icon.APPLICATIONS title="" />
32 <Badge>{pending.length}</Badge>
37 onHide={() => setShowDialog(false)}
39 tournament={tournament}
44 ApplicationsButton.propTypes = {
45 tournament: PropTypes.shape({
46 accept_applications: PropTypes.bool,
49 user: PropTypes.shape({
53 export default withTranslation()(withUser(ApplicationsButton));