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);
onClick={() => setShowDialog(true)}
variant="secondary"
>
- {i18n.t(findResult(participant, round) ? 'results.edit' : 'results.report')}
+ {getButtonLabel(participant, round)}
{' '}
<Icon.EDIT title="" />
</Button>