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 ReportDialog from './ReportDialog';
7 import Icon from '../common/Icon';
8 import { findResult } from '../../helpers/Participant';
9 import i18n from '../../i18n';
11 const getButtonLabel = (participant, round) => {
12 const result = findResult(participant, round);
14 if (result && result.comment) {
15 return i18n.t('results.editComment');
17 return i18n.t('results.addComment');
20 if (result && (result.time || result.forfeit)) {
21 return i18n.t('results.edit');
23 return i18n.t('results.report');
28 const ReportButton = ({ participant, round }) => {
29 const [showDialog, setShowDialog] = useState(false);
33 onClick={() => setShowDialog(true)}
36 {getButtonLabel(participant, round)}
38 <Icon.EDIT title="" />
41 onHide={() => setShowDialog(false)}
42 participant={participant}
49 ReportButton.propTypes = {
50 participant: PropTypes.shape({
52 round: PropTypes.shape({
54 tournament: PropTypes.shape({
58 export default withTranslation()(ReportButton);