@@ -46,7 +46,8 @@ const ChallengeViewTabs = ({
4646 projectPhases,
4747 assignYourselfCopilot,
4848 showRejectChallengeModal,
49- loggedInUser
49+ loggedInUser,
50+ onApproveChallenge
5051} ) => {
5152 const [ selectedTab , setSelectedTab ] = useState ( 0 )
5253
@@ -85,7 +86,9 @@ const ChallengeViewTabs = ({
8586
8687 const isSelfService = challenge . legacy . selfService
8788 const isDraft = challenge . status . toUpperCase ( ) === CHALLENGE_STATUS . DRAFT
88- const launchText = `${ isSelfService && isDraft ? 'Approve and ' : '' } Launch`
89+ // if this isn't self-service, permit launching if the challenge is draft
90+ // OR if this is self-service, permit launching if the challenge is approved
91+ const canLaunch = ( ! isSelfService && isDraft ) || challenge . status . toUpperCase ( ) === CHALLENGE_STATUS . APPROVED
8992 const isCopilot = challenge . legacy . selfServiceCopilot === loggedInUser . handle
9093
9194 return (
@@ -117,12 +120,12 @@ const ChallengeViewTabs = ({
117120 >
118121 { ( isDraft || challenge . status === 'New' ) && ! isSelfService &&
119122 ( < div className = { styles [ 'cancel-button' ] } > < CancelDropDown challenge = { challenge } onSelectMenu = { cancelChallenge } /> </ div > ) }
120- { isDraft && ( ! isSelfService || isCopilot ) && (
123+ { canLaunch && (
121124 < div className = { styles . button } >
122125 { challenge . legacyId || isTask ? (
123126 < PrimaryButton
124- text = { launchText }
125- type = { 'info' }
127+ text = 'Launch'
128+ type = 'info'
126129 onClick = { onLaunchChallenge }
127130 />
128131 ) : (
@@ -133,6 +136,15 @@ const ChallengeViewTabs = ({
133136 ) }
134137 </ div >
135138 ) }
139+ { isDraft && isSelfService && (
140+ < div className = { styles . button } >
141+ < PrimaryButton
142+ text = 'Approve'
143+ type = 'info'
144+ onClick = { onApproveChallenge }
145+ />
146+ </ div >
147+ ) }
136148 { isTask && challenge . status === 'Active' && (
137149 < div className = { styles . button } >
138150 { assignedMemberDetails ? (
@@ -153,8 +165,8 @@ const ChallengeViewTabs = ({
153165 { isSelfService && isDraft && isCopilot && (
154166 < div className = { styles . button } >
155167 < PrimaryButton
156- text = { 'Reject challenge' }
157- type = { 'danger' }
168+ text = 'Reject challenge'
169+ type = 'danger'
158170 onClick = { showRejectChallengeModal }
159171 />
160172 </ div >
@@ -228,6 +240,7 @@ const ChallengeViewTabs = ({
228240 projectPhases = { projectPhases }
229241 assignYourselfCopilot = { assignYourselfCopilot }
230242 showRejectChallengeModal = { showRejectChallengeModal }
243+ onApproveChallenge = { onApproveChallenge }
231244 />
232245 ) }
233246 { selectedTab === 1 && (
@@ -267,7 +280,8 @@ ChallengeViewTabs.propTypes = {
267280 projectPhases : PropTypes . arrayOf ( PropTypes . object ) ,
268281 assignYourselfCopilot : PropTypes . func . isRequired ,
269282 showRejectChallengeModal : PropTypes . func . isRequired ,
270- loggedInUser : PropTypes . object . isRequired
283+ loggedInUser : PropTypes . object . isRequired ,
284+ onApproveChallenge : PropTypes . func
271285}
272286
273287export default ChallengeViewTabs
0 commit comments