1 import axios from 'axios';
2 import PropTypes from 'prop-types';
3 import React from 'react';
4 import { Alert, Button, Modal } from 'react-bootstrap';
5 import { withTranslation } from 'react-i18next';
6 import toastr from 'toastr';
8 import { isComplete } from '../../helpers/Round';
9 import i18n from '../../i18n';
17 <Modal className="lock-dialog" onHide={onHide} show={show}>
18 <Modal.Header closeButton>
20 {i18n.t(round.locked ? 'rounds.unlock' : 'rounds.lock')}
24 <p>{i18n.t(round.locked
25 ? 'rounds.unlockDescription'
26 : 'rounds.lockDescription')}
28 {!round.locked && tournament.type === 'signup-async' && !isComplete(tournament, round) ?
29 <Alert variant="warning">
30 {i18n.t('rounds.lockIncompleteWarning')}
36 <Button onClick={onHide} variant="secondary">
37 {i18n.t('button.cancel')}
41 onClick={async () => {
44 await axios.post(`/api/rounds/${round.id}/unlock`);
45 toastr.success(i18n.t('rounds.unlockSuccess'));
48 toastr.error(i18n.t('rounds.unlockError'));
52 await axios.post(`/api/rounds/${round.id}/lock`);
53 toastr.success(i18n.t('rounds.lockSuccess'));
56 toastr.error(i18n.t('rounds.lockError'));
62 {i18n.t(round.locked ? 'rounds.unlock' : 'rounds.lock')}
67 LockDialog.propTypes = {
68 onHide: PropTypes.func,
69 round: PropTypes.shape({
71 locked: PropTypes.bool,
74 tournament: PropTypes.shape({
75 type: PropTypes.string,
79 export default withTranslation()(LockDialog);