diff --git a/src/components/ChallengeEditor/Copilot-Field/Copilot-Field.module.scss b/src/components/ChallengeEditor/Copilot-Field/Copilot-Field.module.scss index 1a272eed..d50a3f10 100644 --- a/src/components/ChallengeEditor/Copilot-Field/Copilot-Field.module.scss +++ b/src/components/ChallengeEditor/Copilot-Field/Copilot-Field.module.scss @@ -31,6 +31,11 @@ display: flex; align-items: center; } + + &.col2.error { + color: $tc-red; + margin-top: -25px; + } &.col2 { align-self: flex-end; diff --git a/src/components/ChallengeEditor/Copilot-Field/index.js b/src/components/ChallengeEditor/Copilot-Field/index.js index 4d092d22..38607cdd 100644 --- a/src/components/ChallengeEditor/Copilot-Field/index.js +++ b/src/components/ChallengeEditor/Copilot-Field/index.js @@ -6,8 +6,11 @@ import _ from 'lodash' import CopilotCard from '../../CopilotCard' const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly }) => { + let errMessage = 'Please set a copilot' + const selectedCopilot = _.find(copilots, { handle: challenge.copilot }) + const copilotFee = _.find(challenge.prizeSets, p => p.type === 'copilot', []) + console.log(copilotFee) if (readOnly) { - const selectedCopilot = _.find(copilots, { handle: challenge.copilot }) return (
@@ -20,17 +23,27 @@ const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly }) => { ) } return ( -
-
- -
-
- { - _.map(copilots, copilot => ( - )) - } + <> +
+
+ +
+
+ { + _.map(copilots, copilot => ( + )) + } +
-
+ {!readOnly && challenge.submitTriggered && parseInt(copilotFee.prizes[0].value) > 0 && !selectedCopilot && ( +
+
+
+ {errMessage} +
+
+ )} + ) } diff --git a/src/components/ChallengeEditor/index.js b/src/components/ChallengeEditor/index.js index 2d4bdef7..1892bbf5 100644 --- a/src/components/ChallengeEditor/index.js +++ b/src/components/ChallengeEditor/index.js @@ -706,6 +706,14 @@ class ChallengeEditor extends Component { }) } + checkValidCopilot () { + const copilotFee = _.find(this.state.challenge.prizeSets, p => p.type === PRIZE_SETS_TYPE.COPILOT_PAYMENT, []) + if (copilotFee && parseInt(copilotFee.prizes[0].value) > 0 && !this.state.challenge.copilot) { + return false + } + return true + } + isValidChallenge () { const { challenge } = this.state if (this.props.isNew) { @@ -723,6 +731,10 @@ class ChallengeEditor extends Component { return false } + if (!this.checkValidCopilot()) { + return false + } + const requiredFields = [ 'trackId', 'typeId', @@ -1376,11 +1388,15 @@ class ChallengeEditor extends Component {
*/}
- + { !this.state.hasValidationErrors ? ( + + ) : ( + + )}
{isDraft && (
- {challenge.legacyId || isTask ? ( + {(challenge.legacyId || isTask) && !this.state.hasValidationErrors ? ( ) : (