11import React from 'react'
22import PropTypes from 'prop-types'
3+ import { PrimaryButton } from '../../Buttons'
34import styles from './Copilot-Field.module.scss'
45import cn from 'classnames'
56import _ from 'lodash'
67import CopilotCard from '../../CopilotCard'
78
8- const CopilotField = ( { copilots, challenge, onUpdateOthers, readOnly } ) => {
9+ const CopilotField = ( { copilots, challenge, onUpdateOthers, readOnly, assignYourselfCopilit } ) => {
910 let errMessage = 'Please set a copilot'
1011 const selectedCopilot = _ . find ( copilots , { handle : challenge . copilot } )
1112 const copilotFee = _ . find ( challenge . prizeSets , p => p . type === 'copilot' , [ ] )
12- console . log ( copilotFee )
13+ const selfService = challenge . selfService
14+
1315 if ( readOnly ) {
1416 return (
1517 < div className = { styles . row } >
1618 < div className = { cn ( styles . field , styles . col1 ) } >
17- < label htmlFor = 'copilot' > Copilot :</ label >
19+ < label htmlFor = 'copilot' > Copilot:</ label >
1820 </ div >
19- { selectedCopilot && ( < div className = { cn ( styles . field , styles . col2 ) } >
20- < CopilotCard copilot = { selectedCopilot } selectedCopilot = '' key = { selectedCopilot . handle } />
21+ { ( selectedCopilot || selfService ) && ( < div className = { cn ( styles . field , styles . col2 ) } >
22+ { ( selectedCopilot && < CopilotCard copilot = { selectedCopilot } selectedCopilot = '' key = { selectedCopilot . handle } /> ) }
23+ { ( selfService && < PrimaryButton
24+ text = { 'Assign Yourself' }
25+ type = { 'info' }
26+ onClick = { assignYourselfCopilit }
27+ /> ) }
2128 </ div > ) }
2229 </ div >
2330 )
@@ -26,7 +33,7 @@ const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly }) => {
2633 < >
2734 < div className = { styles . row } >
2835 < div className = { cn ( styles . field , styles . col1 ) } >
29- < label htmlFor = 'copilot' > Copilot :</ label >
36+ < label htmlFor = 'copilot' > Copilot:</ label >
3037 </ div >
3138 < div className = { cn ( styles . field , styles . col2 ) } >
3239 {
@@ -49,15 +56,16 @@ const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly }) => {
4956
5057CopilotField . defaultProps = {
5158 copilots : [ ] ,
52- onUpdateOthers : ( ) => { } ,
59+ onUpdateOthers : ( ) => { } ,
5360 readOnly : false
5461}
5562
5663CopilotField . propTypes = {
5764 copilots : PropTypes . arrayOf ( PropTypes . shape ( ) ) . isRequired ,
5865 challenge : PropTypes . shape ( ) . isRequired ,
5966 onUpdateOthers : PropTypes . func ,
60- readOnly : PropTypes . bool
67+ readOnly : PropTypes . bool ,
68+ assignYourselfCopilit : PropTypes . func . isRequired
6169}
6270
6371export default CopilotField
0 commit comments