@@ -74,6 +74,7 @@ class ChallengeEditor extends Component {
7474 this . assignYourselfCopilot = this . assignYourselfCopilot . bind ( this )
7575 this . showRejectChallengeModal = this . showRejectChallengeModal . bind ( this )
7676 this . closeRejectModal = this . closeRejectModal . bind ( this )
77+ this . rejectChallenge = this . rejectChallenge . bind ( this )
7778 }
7879
7980 componentDidMount ( ) {
@@ -321,23 +322,35 @@ class ChallengeEditor extends Component {
321322
322323 async assignYourselfCopilot ( ) {
323324 const { challengeDetails, loggedInUser, metadata, createResource } = this . props
325+
326+ // create the role resource
324327 const copilotRole = getResourceRoleByName ( metadata . resourceRoles , 'Copilot' )
325328 const copilotHandle = loggedInUser . handle
326329 await createResource ( challengeDetails . id , copilotRole . id , copilotHandle )
327- const updatedChallenge = await patchChallenge ( challengeDetails . id , {
330+
331+ // update the challenge
332+ const partialChallenge = {
328333 legacy : {
329334 selfServiceCopilot : copilotHandle
330335 }
331- } )
336+ }
337+ const updatedChallenge = await patchChallenge ( challengeDetails . id , partialChallenge )
332338 this . setState ( { challengeDetails : updatedChallenge } )
333339 }
334340
335341 showRejectChallengeModal ( ) {
336342 this . setState ( { showRejectModal : true } )
337343 }
338344
339- rejectChallenge ( ) {
340- console . debug ( 'rejecting' )
345+ async rejectChallenge ( ) {
346+ const { challengeDetails } = this . props
347+ const partialChallenge = {
348+ status : 'Cancelled - Requirements Infeasible' ,
349+ cancelReason : 'TODO' // TODO
350+ }
351+ const updatedChallenge = await patchChallenge ( challengeDetails . id , partialChallenge )
352+ this . setState ( { challengeDetails : updatedChallenge } )
353+ this . closeRejectModal ( )
341354 }
342355
343356 render ( ) {
0 commit comments