@@ -59,7 +59,8 @@ class ChallengeEditor extends Component {
5959 isLaunching : false ,
6060 showSuccessModal : false ,
6161 showLaunchModal : false ,
62- showRejectModal : false
62+ showRejectModal : false ,
63+ cancelReason : null
6364 }
6465
6566 this . onLaunchChallenge = this . onLaunchChallenge . bind ( this )
@@ -75,6 +76,7 @@ class ChallengeEditor extends Component {
7576 this . showRejectChallengeModal = this . showRejectChallengeModal . bind ( this )
7677 this . closeRejectModal = this . closeRejectModal . bind ( this )
7778 this . rejectChallenge = this . rejectChallenge . bind ( this )
79+ this . onChangeCancelReason = this . onChangeCancelReason . bind ( this )
7880 }
7981
8082 componentDidMount ( ) {
@@ -328,13 +330,15 @@ class ChallengeEditor extends Component {
328330 const copilotHandle = loggedInUser . handle
329331 await createResource ( challengeDetails . id , copilotRole . id , copilotHandle )
330332
331- this . setState ( { challengeDetails : {
332- ...challengeDetails ,
333- legacy : {
334- ...challengeDetails . legacy ,
335- selfServiceCopilot : copilotHandle
333+ this . setState ( {
334+ challengeDetails : {
335+ ...challengeDetails ,
336+ legacy : {
337+ ...challengeDetails . legacy ,
338+ selfServiceCopilot : copilotHandle
339+ }
336340 }
337- } } )
341+ } )
338342 }
339343
340344 showRejectChallengeModal ( ) {
@@ -343,15 +347,20 @@ class ChallengeEditor extends Component {
343347
344348 async rejectChallenge ( ) {
345349 const { challengeDetails } = this . props
350+ const { cancelReason } = this . state
346351 const partialChallenge = {
347352 status : 'Cancelled - Requirements Infeasible' ,
348- cancelReason : 'TODO' // TODO
353+ cancelReason : cancelReason
349354 }
350355 const updatedChallenge = await patchChallenge ( challengeDetails . id , partialChallenge )
351356 this . setState ( { challengeDetails : updatedChallenge } )
352357 this . closeRejectModal ( )
353358 }
354359
360+ onChangeCancelReason ( reason ) {
361+ this . setState ( { cancelReason : reason } )
362+ }
363+
355364 render ( ) {
356365 const {
357366 match,
@@ -389,7 +398,8 @@ class ChallengeEditor extends Component {
389398 showSuccessModal,
390399 suceessMessage,
391400 challengeDetails,
392- showRejectModal
401+ showRejectModal,
402+ cancelReason
393403 } = this . state
394404 if ( isProjectLoading || isLoading || isProjectPhasesLoading ) return < Loader />
395405 const challengeId = _ . get ( match . params , 'challengeId' , null )
@@ -441,26 +451,27 @@ class ChallengeEditor extends Component {
441451 onClose = { this . closeSuccessModal }
442452 />
443453 )
454+ const rejectModalContainerClasses = `${ modalStyles . contentContainer } ${ styles . rejectChallengeContainer } `
444455 const rejectModal = (
445456 < Modal theme = { theme } onCancel = { this . closeRejectModal } >
446- < div className = { modalStyles . contentContainer } >
457+ < div className = { rejectModalContainerClasses } >
447458 < div className = { modalStyles . title } > Reject Challenge</ div >
448459 < span > Please provide a reason for rejecting "{ challengeDetails . name } ?"</ span >
449- < div className = { modalStyles . buttonGroup } >
450- < div className = { modalStyles . buttonSizeA } >
451- < PrimaryButton
452- text = 'Reject challenge'
453- type = 'danger'
454- onClick = { this . rejectChallenge }
455- />
456- </ div >
457- < div className = { modalStyles . buttonSizeA } >
458- < OutlineButton
459- text = 'Cancel'
460- type = 'info '
461- onClick = { this . closeRejectModal }
462- />
463- </ div >
460+ < div className = { styles . cancelReasonContainer } >
461+ < textarea id = 'cancelReason' name = 'cancelReason' placeholder = 'Enter your reason' rows = '4' className = { styles . cancelReason } onChange = { e => this . onChangeCancelReason ( e . target . value ) } / >
462+ </ div >
463+ < div className = { styles . rejectButtonContainer } >
464+ < PrimaryButton
465+ text = 'Reject challenge'
466+ type = 'danger'
467+ onClick = { this . rejectChallenge }
468+ disabled = { _ . isEmpty ( cancelReason ) }
469+ />
470+ < OutlineButton
471+ text = 'Cancel '
472+ type = 'info'
473+ onClick = { this . closeRejectModal }
474+ / >
464475 </ div >
465476 </ div >
466477 </ Modal >
0 commit comments