Skip to content

Commit 18f1aed

Browse files
committed
fix issue #1176
1 parent 51c2948 commit 18f1aed

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

src/components/ChallengeEditor/Copilot-Field/Copilot-Field.module.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
white-space: nowrap;
3131
display: flex;
3232
align-items: center;
33+
span {
34+
color: $tc-red;
35+
}
36+
}
37+
38+
&.col2.error {
39+
color: $tc-red;
40+
margin-top: -25px;
3341
}
3442

3543
&.col2 {

src/components/ChallengeEditor/Copilot-Field/index.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import _ from 'lodash'
66
import CopilotCard from '../../CopilotCard'
77

88
const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly }) => {
9+
let errMessage = 'Please set a copilot'
10+
const selectedCopilot = _.find(copilots, { handle: challenge.copilot })
911
if (readOnly) {
10-
const selectedCopilot = _.find(copilots, { handle: challenge.copilot })
1112
return (
1213
<div className={styles.row}>
1314
<div className={cn(styles.field, styles.col1)}>
@@ -20,17 +21,27 @@ const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly }) => {
2021
)
2122
}
2223
return (
23-
<div className={styles.row}>
24-
<div className={cn(styles.field, styles.col1)}>
25-
<label htmlFor='copilot'>Copilot :</label>
26-
</div>
27-
<div className={cn(styles.field, styles.col2)}>
28-
{
29-
_.map(copilots, copilot => (
30-
<CopilotCard copilot={copilot} selectedCopilot={challenge.copilot} key={copilot.handle} onUpdateOthers={onUpdateOthers} />))
31-
}
24+
<>
25+
<div className={styles.row}>
26+
<div className={cn(styles.field, styles.col1)}>
27+
<label htmlFor='copilot'>Copilot {!readOnly && (<span>*</span>)} :</label>
28+
</div>
29+
<div className={cn(styles.field, styles.col2)}>
30+
{
31+
_.map(copilots, copilot => (
32+
<CopilotCard copilot={copilot} selectedCopilot={challenge.copilot} key={copilot.handle} onUpdateOthers={onUpdateOthers} />))
33+
}
34+
</div>
3235
</div>
33-
</div>
36+
{!readOnly && challenge.submitTriggered && !selectedCopilot && (
37+
<div className={styles.row}>
38+
<div className={cn(styles.field, styles.col1)} />
39+
<div className={cn(styles.field, styles.col2, styles.error)}>
40+
{errMessage}
41+
</div>
42+
</div>
43+
)}
44+
</>
3445
)
3546
}
3647

src/components/ChallengeEditor/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ class ChallengeEditor extends Component {
727727
'trackId',
728728
'typeId',
729729
'name',
730+
'copilot',
730731
'description',
731732
'tags',
732733
'prizeSets'

0 commit comments

Comments
 (0)