@@ -8,6 +8,7 @@ import ChallengeViewTabs from '../../components/ChallengeEditor/ChallengeViewTab
88import Loader from '../../components/Loader'
99import { checkAdmin , getResourceRoleByName } from '../../util/tc'
1010import styles from './ChallengeEditor.module.scss'
11+ import modalStyles from '../../components/Modal/ConfirmationModal.module.scss'
1112
1213import {
1314 loadTimelineTemplates ,
@@ -40,6 +41,9 @@ import { SUBMITTER_ROLE_UUID, MESSAGE } from '../../config/constants'
4041import { patchChallenge } from '../../services/challenges'
4142import ConfirmationModal from '../../components/Modal/ConfirmationModal'
4243import AlertModal from '../../components/Modal/AlertModal'
44+ import Modal from '../../components/Modal'
45+ import PrimaryButton from '../../components/Buttons/PrimaryButton'
46+ import OutlineButton from '../../components/Buttons/OutlineButton'
4347
4448const theme = {
4549 container : styles . modalContainer
@@ -54,7 +58,8 @@ class ChallengeEditor extends Component {
5458 mountedWithCreatePage,
5559 isLaunching : false ,
5660 showSuccessModal : false ,
57- showLaunchModal : false
61+ showLaunchModal : false ,
62+ showRejectModal : false
5863 }
5964
6065 this . onLaunchChallenge = this . onLaunchChallenge . bind ( this )
@@ -67,6 +72,8 @@ class ChallengeEditor extends Component {
6772 this . closeTask = this . closeTask . bind ( this )
6873 this . fetchProjectDetails = this . fetchProjectDetails . bind ( this )
6974 this . assignYourselfCopilot = this . assignYourselfCopilot . bind ( this )
75+ this . showRejectChallengeModal = this . showRejectChallengeModal . bind ( this )
76+ this . closeRejectModal = this . closeRejectModal . bind ( this )
7077 }
7178
7279 componentDidMount ( ) {
@@ -218,6 +225,10 @@ class ChallengeEditor extends Component {
218225 this . setState ( { showSuccessModal : false } )
219226 }
220227
228+ closeRejectModal ( ) {
229+ this . setState ( { showRejectModal : false } )
230+ }
231+
221232 async activateChallenge ( ) {
222233 const { partiallyUpdateChallengeDetails } = this . props
223234 if ( this . state . isLaunching ) return
@@ -311,11 +322,15 @@ class ChallengeEditor extends Component {
311322 async assignYourselfCopilot ( ) {
312323 const { challengeDetails, loggedInUser, metadata, createResource } = this . props
313324 const copilotRole = getResourceRoleByName ( metadata . resourceRoles , 'Copilot' )
314- await createResource ( challengeDetails . id , copilotRole . id , loggedInUser . handle )
325+ createResource ( challengeDetails . id , copilotRole . id , loggedInUser . handle )
326+ }
327+
328+ showRejectChallengeModal ( ) {
329+ this . setState ( { showRejectModal : true } )
315330 }
316331
317332 rejectChallenge ( ) {
318- console . debug ( 'rejecting challenge ' )
333+ console . debug ( 'rejecting' )
319334 }
320335
321336 render ( ) {
@@ -343,7 +358,8 @@ class ChallengeEditor extends Component {
343358 loggedInUser,
344359 projectPhases,
345360 isProjectPhasesLoading,
346- rejectChallenge
361+ rejectChallenge,
362+ showRejectChallengeModal
347363 // members
348364 } = this . props
349365 const {
@@ -353,7 +369,8 @@ class ChallengeEditor extends Component {
353369 showCloseTaskModal,
354370 showSuccessModal,
355371 suceessMessage,
356- challengeDetails
372+ challengeDetails,
373+ showRejectModal
357374 } = this . state
358375 if ( isProjectLoading || isLoading || isProjectPhasesLoading ) return < Loader />
359376 const challengeId = _ . get ( match . params , 'challengeId' , null )
@@ -405,11 +422,36 @@ class ChallengeEditor extends Component {
405422 onClose = { this . closeSuccessModal }
406423 />
407424 )
425+ const rejectModal = (
426+ < Modal theme = { theme } onCancel = { this . closeRejectModal } >
427+ < div className = { modalStyles . contentContainer } >
428+ < div className = { modalStyles . title } > Reject Challenge</ div >
429+ < span > Please provide a reason for rejecting "{ challengeDetails . name } ?"</ span >
430+ < div className = { modalStyles . buttonGroup } >
431+ < div className = { modalStyles . buttonSizeA } >
432+ < PrimaryButton
433+ text = 'Reject challenge'
434+ type = 'danger'
435+ onClick = { this . rejectChallenge }
436+ />
437+ </ div >
438+ < div className = { modalStyles . buttonSizeA } >
439+ < OutlineButton
440+ text = 'Cancel'
441+ type = 'info'
442+ onClick = { this . closeRejectModal }
443+ />
444+ </ div >
445+ </ div >
446+ </ div >
447+ </ Modal >
448+ )
408449 return (
409450 < div >
410451 { showLaunchModal && activateModal }
411452 { showCloseTaskModal && closeTaskModal }
412453 { showSuccessModal && successModal }
454+ { showRejectModal && rejectModal }
413455 < Route
414456 exact
415457 path = { this . props . match . path }
@@ -439,6 +481,7 @@ class ChallengeEditor extends Component {
439481 projectPhases = { projectPhases }
440482 assignYourselfCopilot = { this . assignYourselfCopilot }
441483 rejectChallenge = { rejectChallenge }
484+ showRejectChallengeModal = { showRejectChallengeModal }
442485 loggedInUser = { loggedInUser }
443486 />
444487 ) }
@@ -505,7 +548,7 @@ class ChallengeEditor extends Component {
505548 onLaunchChallenge = { this . onLaunchChallenge }
506549 onCloseTask = { this . onCloseTask }
507550 assignYourselfCopilot = { this . assignYourselfCopilot }
508- rejectChallenge = { this . rejectChallenge }
551+ showRejectChallengeModal = { this . showRejectChallengeModal }
509552 loggedInUser = { loggedInUser }
510553 />
511554 ) }
@@ -563,7 +606,8 @@ ChallengeEditor.propTypes = {
563606 loadProject : PropTypes . func ,
564607 projectPhases : PropTypes . arrayOf ( PropTypes . object ) ,
565608 isProjectPhasesLoading : PropTypes . bool ,
566- rejectChallenge : PropTypes . func . isRequired
609+ rejectChallenge : PropTypes . func . isRequired ,
610+ showRejectChallengeModal : PropTypes . func
567611 // members: PropTypes.arrayOf(PropTypes.shape())
568612}
569613
0 commit comments