]> git.localhorst.tv Git - alttp.git/blob - resources/js/components/results/ReportButton.js
server calculated scoring
[alttp.git] / resources / js / components / results / ReportButton.js
1 import PropTypes from 'prop-types';
2 import React, { useState } from 'react';
3 import { Button } from 'react-bootstrap';
4 import { withTranslation } from 'react-i18next';
5
6 import ReportDialog from './ReportDialog';
7 import Icon from '../common/Icon';
8 import { findResult } from '../../helpers/Participant';
9 import i18n from '../../i18n';
10
11 const ReportButton = ({ participant, round }) => {
12         const [showDialog, setShowDialog] = useState(false);
13
14         return <>
15                 <Button
16                         onClick={() => setShowDialog(true)}
17                         variant="secondary"
18                 >
19                         {i18n.t(findResult(participant, round) ? 'results.edit' : 'results.report')}
20                         {' '}
21                         <Icon.EDIT title="" />
22                 </Button>
23                 <ReportDialog
24                         onHide={() => setShowDialog(false)}
25                         participant={participant}
26                         round={round}
27                         show={showDialog}
28                 />
29         </>;
30 };
31
32 ReportButton.propTypes = {
33         participant: PropTypes.shape({
34         }),
35         round: PropTypes.shape({
36         }),
37         tournament: PropTypes.shape({
38         }),
39 };
40
41 export default withTranslation()(ReportButton);