1 import PropTypes from 'prop-types';
2 import React, { useState } from 'react';
3 import { Button } from 'react-bootstrap';
4 import { useTranslation } from 'react-i18next';
6 import LockDialog from './LockDialog';
7 import Icon from '../common/Icon';
8 import { mayLockRound } from '../../helpers/permissions';
9 import { useUser } from '../../hooks/user';
15 const [showDialog, setShowDialog] = useState(false);
17 const { t } = useTranslation();
18 const { user } = useUser();
20 if (!mayLockRound(user, tournament, round)) {
22 return <Icon.LOCKED title={t('rounds.locked')} />;
24 return <Icon.UNLOCKED title={t('rounds.unlocked')} />;
30 onHide={() => setShowDialog(false)}
33 tournament={tournament}
36 onClick={() => setShowDialog(true)}
38 title={t(round.locked ? 'rounds.locked' : 'rounds.unlocked')}
39 variant="outline-secondary"
42 <Icon.LOCKED title="" />
44 <Icon.UNLOCKED title="" />
50 LockButton.propTypes = {
51 round: PropTypes.shape({
52 locked: PropTypes.bool,
54 tournament: PropTypes.shape({
58 export default LockButton;