X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fresults%2FReportButton.js;h=0a8c139469db478b09fde94cdd342249dba56d46;hb=8d97d023740e438361e659c6e133418e33343178;hp=d88c1a11285ee5ed72543f70f65421b5a6100fc2;hpb=d748feb96453d74aeffec648d6f5f68d9ef3b520;p=alttp.git diff --git a/resources/js/components/results/ReportButton.js b/resources/js/components/results/ReportButton.js index d88c1a1..0a8c139 100644 --- a/resources/js/components/results/ReportButton.js +++ b/resources/js/components/results/ReportButton.js @@ -8,6 +8,23 @@ import Icon from '../common/Icon'; import { findResult } from '../../helpers/Participant'; import i18n from '../../i18n'; +const getButtonLabel = (participant, round) => { + const result = findResult(participant, round); + if (round.locked) { + if (result && result.comment) { + return i18n.t('results.editComment'); + } else { + return i18n.t('results.addComment'); + } + } else { + if (result && (result.time || result.forfeit)) { + return i18n.t('results.edit'); + } else { + return i18n.t('results.report'); + } + } +}; + const ReportButton = ({ participant, round }) => { const [showDialog, setShowDialog] = useState(false); @@ -16,7 +33,7 @@ const ReportButton = ({ participant, round }) => { onClick={() => setShowDialog(true)} variant="secondary" > - {i18n.t(findResult(participant, round) ? 'results.edit' : 'results.report')} + {getButtonLabel(participant, round)} {' '}