1 import PropTypes from 'prop-types';
2 import React, { useState } from 'react';
3 import { Button } from 'react-bootstrap';
4 import { withTranslation } from 'react-i18next';
6 import LockDialog from './LockDialog';
7 import Icon from '../common/Icon';
8 import { mayLockRound } from '../../helpers/permissions';
9 import { withUser } from '../../helpers/UserContext';
10 import i18n from '../../i18n';
17 const [showDialog, setShowDialog] = useState(false);
19 if (!mayLockRound(user, tournament, round)) {
21 return <Icon.LOCKED title={i18n.t('rounds.locked')} />;
23 return <Icon.UNLOCKED title={i18n.t('rounds.unlocked')} />;
29 onHide={() => setShowDialog(false)}
32 tournament={tournament}
35 onClick={() => setShowDialog(true)}
37 title={round.locked ? i18n.t('rounds.locked') : i18n.t('rounds.unlocked') }
38 variant="outline-secondary"
41 <Icon.LOCKED title="" />
43 <Icon.UNLOCKED title="" />
49 LockButton.propTypes = {
50 round: PropTypes.shape({
51 locked: PropTypes.bool,
53 tournament: PropTypes.shape({
55 user: PropTypes.shape({
59 export default withTranslation()(withUser(LockButton));