X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fresults%2FReportButton.js;h=9db944ee79ace429eed3928e6d4b5bcd10440768;hb=60fd718e3b558eaea02a8d64bd6aac74be91f782;hp=0a8c139469db478b09fde94cdd342249dba56d46;hpb=a4260a00251cef4ad806c9d5c44d4c444d6ab831;p=alttp.git diff --git a/resources/js/components/results/ReportButton.js b/resources/js/components/results/ReportButton.js index 0a8c139..9db944e 100644 --- a/resources/js/components/results/ReportButton.js +++ b/resources/js/components/results/ReportButton.js @@ -5,11 +5,11 @@ import { withTranslation } from 'react-i18next'; import ReportDialog from './ReportDialog'; import Icon from '../common/Icon'; -import { findResult } from '../../helpers/Participant'; +import { findResult } from '../../helpers/User'; import i18n from '../../i18n'; -const getButtonLabel = (participant, round) => { - const result = findResult(participant, round); +const getButtonLabel = (user, round) => { + const result = findResult(user, round); if (round.locked) { if (result && result.comment) { return i18n.t('results.editComment'); @@ -25,34 +25,39 @@ const getButtonLabel = (participant, round) => { } }; -const ReportButton = ({ participant, round }) => { +const ReportButton = ({ round, user }) => { const [showDialog, setShowDialog] = useState(false); + if (round.locked && !findResult(user, round)) { + return null; + } + return <> setShowDialog(false)} - participant={participant} round={round} show={showDialog} + user={user} /> ; }; ReportButton.propTypes = { - participant: PropTypes.shape({ - }), round: PropTypes.shape({ + locked: PropTypes.bool, }), tournament: PropTypes.shape({ }), + user: PropTypes.shape({ + }), }; export default withTranslation()(ReportButton);