@@ -13,7 +13,7 @@ import LegacyLinks from '../../LegacyLinks'
13
13
import ForumLink from '../../ForumLink'
14
14
import Registrants from '../Registrants'
15
15
import Submissions from '../Submissions'
16
- import { getResourceRoleByName } from '../../../util/tc'
16
+ import { checkAdmin , getResourceRoleByName } from '../../../util/tc'
17
17
import { CHALLENGE_STATUS , MESSAGE } from '../../../config/constants'
18
18
import Tooltip from '../../Tooltip'
19
19
import CancelDropDown from '../Cancel-Dropdown'
@@ -86,13 +86,16 @@ const ChallengeViewTabs = ({
86
86
87
87
const isSelfService = challenge . legacy . selfService
88
88
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
91
92
// only the copilot can launch AND
92
93
// if this isn't self-service, permit launching if the challenge is draft
93
94
// 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' ) )
96
99
return (
97
100
< div className = { styles . list } >
98
101
< Helmet title = 'View Details' />
@@ -164,7 +167,7 @@ const ChallengeViewTabs = ({
164
167
{ enableEdit && ! isSelfService && (
165
168
< PrimaryButton text = { 'Edit' } type = { 'info' } submit link = { `./edit` } />
166
169
) }
167
- { isSelfService && isDraft && isCopilot && (
170
+ { isSelfService && isDraft && ( isAdmin || isSelfServiceCopilot ) && (
168
171
< div className = { styles . button } >
169
172
< PrimaryButton
170
173
text = 'Reject challenge'
0 commit comments