@@ -13,7 +13,7 @@ import LegacyLinks from '../../LegacyLinks'
1313import ForumLink from '../../ForumLink'
1414import Registrants from '../Registrants'
1515import Submissions from '../Submissions'
16- import { getResourceRoleByName } from '../../../util/tc'
16+ import { checkAdmin , getResourceRoleByName } from '../../../util/tc'
1717import { CHALLENGE_STATUS , MESSAGE } from '../../../config/constants'
1818import Tooltip from '../../Tooltip'
1919import CancelDropDown from '../Cancel-Dropdown'
@@ -86,13 +86,16 @@ const ChallengeViewTabs = ({
8686
8787 const isSelfService = challenge . legacy . selfService
8888 const isDraft = challenge . status . toUpperCase ( ) === CHALLENGE_STATUS . DRAFT
89- const isCopilot = challenge . legacy . selfServiceCopilot === loggedInUser . handle
90- const canApprove = isCopilot && isDraft && isSelfService
89+ const isSelfServiceCopilot = challenge . legacy . selfServiceCopilot === loggedInUser . handle
90+ const isAdmin = checkAdmin ( token )
91+ const canApprove = isSelfServiceCopilot && isDraft && isSelfService
9192 // only the copilot can launch AND
9293 // if this isn't self-service, permit launching if the challenge is draft
9394 // OR if this is self-service, permit launching if the challenge is approved
94- const canLaunch = isCopilot && ( ( ! isSelfService && isDraft ) || challenge . status . toUpperCase ( ) === CHALLENGE_STATUS . APPROVED )
95-
95+ const hasBA = _ . get ( projectDetail , 'billingAccountId' ) !== null
96+ const canLaunch = hasBA && ( ( ! isSelfService && isDraft ) || ( ( isSelfServiceCopilot || isAdmin ) && challenge . status . toUpperCase ( ) === CHALLENGE_STATUS . APPROVED ) )
97+ console . log ( `can launch ${ _ . isEmpty ( _ . get ( projectDetail , 'billingAccountId' ) ) } ` )
98+ console . log ( _ . get ( projectDetail , 'billingAccountId' ) )
9699 return (
97100 < div className = { styles . list } >
98101 < Helmet title = 'View Details' />
@@ -164,7 +167,7 @@ const ChallengeViewTabs = ({
164167 { enableEdit && ! isSelfService && (
165168 < PrimaryButton text = { 'Edit' } type = { 'info' } submit link = { `./edit` } />
166169 ) }
167- { isSelfService && isDraft && isCopilot && (
170+ { isSelfService && isDraft && ( isAdmin || isSelfServiceCopilot ) && (
168171 < div className = { styles . button } >
169172 < PrimaryButton
170173 text = 'Reject challenge'
0 commit comments