From 9258a0cade2f0a35f231910eb5a843c459835e20 Mon Sep 17 00:00:00 2001 From: maxceem Date: Mon, 30 Nov 2020 12:04:55 +0200 Subject: [PATCH] feat: f2f should have only one prize ref issue #865 --- .../ChallengeEditor/ChallengePrizes-Field/index.js | 10 +++++----- src/config/constants.js | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/ChallengeEditor/ChallengePrizes-Field/index.js b/src/components/ChallengeEditor/ChallengePrizes-Field/index.js index 12a850d7..24fb5f83 100644 --- a/src/components/ChallengeEditor/ChallengePrizes-Field/index.js +++ b/src/components/ChallengeEditor/ChallengePrizes-Field/index.js @@ -8,7 +8,7 @@ import PrizeInput from '../../PrizeInput' import styles from './ChallengePrizes-Field.module.scss' import cn from 'classnames' import { PrimaryButton } from '../../Buttons' -import { CHALLENGE_PRIZE_TYPE, VALIDATION_VALUE_TYPE, PRIZE_SETS_TYPE } from '../../../config/constants' +import { CHALLENGE_PRIZE_TYPE, VALIDATION_VALUE_TYPE, PRIZE_SETS_TYPE, CHALLENGE_TYPES_WITH_MULTIPLE_PRIZES } from '../../../config/constants' import { validateValue } from '../../../util/input-check' class ChallengePrizesField extends Component { @@ -61,12 +61,12 @@ class ChallengePrizesField extends Component { renderPrizes () { const { currentPrizeIndex } = this.state const { readOnly, challenge } = this.props - const isTask = _.get(challenge, 'task.isTask', false) + const allowMultiplePrizes = _.includes(CHALLENGE_TYPES_WITH_MULTIPLE_PRIZES, challenge.type) return _.map(this.getChallengePrize().prizes, (prize, index, { length }) => (
- +
{readOnly ? ( ${prize.value} @@ -101,7 +101,7 @@ class ChallengePrizesField extends Component { render () { const { readOnly, challenge } = this.props - const isTask = _.get(challenge, 'task.isTask', false) + const allowMultiplePrizes = _.includes(CHALLENGE_TYPES_WITH_MULTIPLE_PRIZES, challenge.type) return (
@@ -110,7 +110,7 @@ class ChallengePrizesField extends Component {
{ this.renderPrizes() } - {!readOnly && !isTask && (
+ {!readOnly && allowMultiplePrizes && (
)}
diff --git a/src/config/constants.js b/src/config/constants.js index 814ff1f8..344e91fa 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -171,3 +171,8 @@ export const AUTOCOMPLETE_DEBOUNCE_TIME_MS = 150 * Number of groups to retrieve for group dropdown */ export const GROUPS_DROPDOWN_PER_PAGE = 1000000 // make sure we are getting all the groups with one request + +/** + * The list of challenge types which can have multiple prizes + */ +export const CHALLENGE_TYPES_WITH_MULTIPLE_PRIZES = ['Challenge']