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 SeedDialog from './SeedDialog';
7 import { maySetSeed } from '../../helpers/permissions';
8 import { withUser } from '../../helpers/UserContext';
9 import i18n from '../../i18n';
11 const SeedButton = ({ round, tournament, user }) => {
12 const [showDialog, setShowDialog] = useState(false);
16 <Button href={round.seed} target="_blank" variant="primary">
17 {i18n.t('rounds.seed')}
24 variant="outline-primary"
26 {i18n.t('rounds.spoiler')}
31 if (maySetSeed(user, tournament, round)) {
34 onHide={() => setShowDialog(false)}
38 <Button onClick={() => setShowDialog(true)} variant="outline-primary">
39 {i18n.t('rounds.setSeed')}
43 return i18n.t('rounds.noSeed');
46 SeedButton.propTypes = {
47 round: PropTypes.shape({
48 seed: PropTypes.string,
49 spoiler: PropTypes.string,
51 tournament: PropTypes.shape({
53 user: PropTypes.shape({
57 export default withTranslation()(withUser(SeedButton));