@@ -6,8 +6,9 @@ import _ from 'lodash'
66import CopilotCard from '../../CopilotCard'
77
88const 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
0 commit comments