@@ -7,7 +7,7 @@ import PropTypes from 'prop-types'
7
7
import { Helmet } from 'react-helmet'
8
8
import { Link } from 'react-router-dom'
9
9
import ProjectStatus from './ProjectStatus'
10
- import { PROJECT_ROLES , PROJECT_STATUS , COPILOTS_URL } from '../../config/constants'
10
+ import { PROJECT_ROLES , PROJECT_STATUS , COPILOTS_URL , CHALLENGE_STATUS } from '../../config/constants'
11
11
import { PrimaryButton , OutlineButton } from '../Buttons'
12
12
import ChallengeList from './ChallengeList'
13
13
import styles from './ChallengesComponent.module.scss'
@@ -53,6 +53,12 @@ const ChallengesComponent = ({
53
53
const isReadOnly = checkReadOnlyRoles ( auth . token ) || loginUserRoleInProject === PROJECT_ROLES . READ
54
54
const isAdminOrCopilot = checkAdminOrCopilot ( auth . token , activeProject )
55
55
56
+ const projectStatus = activeProject && activeProject . status
57
+ ? activeProject . status . toUpperCase ( )
58
+ : ''
59
+ const isCompletedOrCancelled =
60
+ projectStatus === CHALLENGE_STATUS . CANCELLED || projectStatus === CHALLENGE_STATUS . COMPLETED
61
+
56
62
useEffect ( ( ) => {
57
63
const loggedInUser = auth . user
58
64
const projectMembers = activeProject . members
@@ -94,7 +100,7 @@ const ChallengesComponent = ({
94
100
className = { styles . btnOutline }
95
101
/>
96
102
) }
97
- { ( checkAdmin ( auth . token ) || checkManager ( auth . token ) ) && (
103
+ { ( checkAdmin ( auth . token ) || checkManager ( auth . token ) ) && ! isCompletedOrCancelled && (
98
104
< OutlineButton
99
105
text = 'Request Copilot'
100
106
type = { 'info' }
0 commit comments