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)}
34 onClick={() => setShowDialog(true)}
36 title={round.locked ? i18n.t('rounds.locked') : i18n.t('rounds.unlocked') }
37 variant="outline-secondary"
40 <Icon.LOCKED title="" />
42 <Icon.UNLOCKED title="" />
48 LockButton.propTypes = {
49 round: PropTypes.shape({
50 locked: PropTypes.bool,
52 tournament: PropTypes.shape({
54 user: PropTypes.shape({
58 export default withTranslation()(withUser(LockButton));