@@ -44,7 +44,9 @@ const ChallengeViewTabs = ({
4444 cancelChallenge,
4545 onCloseTask,
4646 projectPhases,
47- assignYourselfCopilit
47+ assignYourselfCopilot,
48+ showRejectChallengeModal,
49+ loggedInUser
4850} ) => {
4951 const [ selectedTab , setSelectedTab ] = useState ( 0 )
5052
@@ -84,6 +86,7 @@ const ChallengeViewTabs = ({
8486 const isSelfService = challenge . legacy . selfService
8587 const isDraft = challenge . status . toUpperCase ( ) === CHALLENGE_STATUS . DRAFT
8688 const launchText = `${ isSelfService && isDraft ? 'Approve and ' : '' } Launch`
89+ const isCopilot = challenge . legacy . selfServiceCopilot === loggedInUser . handle
8790
8891 return (
8992 < div className = { styles . list } >
@@ -112,9 +115,9 @@ const ChallengeViewTabs = ({
112115 styles . actionButtonsRight
113116 ) }
114117 >
115- { ( challenge . status === 'Draft' || challenge . status === 'New' ) && ! isSelfService &&
118+ { ( isDraft || challenge . status === 'New' ) && ! isSelfService &&
116119 ( < div className = { styles [ 'cancel-button' ] } > < CancelDropDown challenge = { challenge } onSelectMenu = { cancelChallenge } /> </ div > ) }
117- { challenge . status === 'Draft' && (
120+ { isDraft && ( ! isSelfService || isCopilot ) && (
118121 < div className = { styles . button } >
119122 { challenge . legacyId || isTask ? (
120123 < PrimaryButton
@@ -147,14 +150,15 @@ const ChallengeViewTabs = ({
147150 { enableEdit && ! isSelfService && (
148151 < PrimaryButton text = { 'Edit' } type = { 'info' } submit link = { `./edit` } />
149152 ) }
150- { isSelfService && isDraft &&
151- (
153+ { isSelfService && isDraft && isCopilot && (
154+ < div className = { styles . button } >
152155 < PrimaryButton
153156 text = { 'Reject challenge' }
154157 type = { 'danger' }
155- onClick = { onLaunchChallenge } // TODO
158+ onClick = { showRejectChallengeModal }
156159 />
157- ) }
160+ </ div >
161+ ) }
158162 < PrimaryButton text = { 'Back' } type = { 'info' } submit link = { `..` } />
159163 </ div >
160164 </ div >
@@ -222,7 +226,8 @@ const ChallengeViewTabs = ({
222226 onLaunchChallenge = { onLaunchChallenge }
223227 onCloseTask = { onCloseTask }
224228 projectPhases = { projectPhases }
225- assignYourselfCopilit = { assignYourselfCopilit }
229+ assignYourselfCopilot = { assignYourselfCopilot }
230+ showRejectChallengeModal = { showRejectChallengeModal }
226231 />
227232 ) }
228233 { selectedTab === 1 && (
@@ -260,7 +265,9 @@ ChallengeViewTabs.propTypes = {
260265 cancelChallenge : PropTypes . func . isRequired ,
261266 onCloseTask : PropTypes . func ,
262267 projectPhases : PropTypes . arrayOf ( PropTypes . object ) ,
263- assignYourselfCopilit : PropTypes . func . isRequired
268+ assignYourselfCopilot : PropTypes . func . isRequired ,
269+ showRejectChallengeModal : PropTypes . func . isRequired ,
270+ loggedInUser : PropTypes . object . isRequired
264271}
265272
266273export default ChallengeViewTabs
0 commit comments