Skip to content

Commit 8ede5aa

Browse files
Merge pull request #1660 from topcoder-platform/PM-1270
PM-1270 Exclude cancelled and completed projects from copilot request creation
2 parents 07b407b + fb89618 commit 8ede5aa

File tree

1 file changed

+8
-2
lines changed
  • src/components/ChallengesComponent

1 file changed

+8
-2
lines changed

src/components/ChallengesComponent/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import PropTypes from 'prop-types'
77
import { Helmet } from 'react-helmet'
88
import { Link } from 'react-router-dom'
99
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'
1111
import { PrimaryButton, OutlineButton } from '../Buttons'
1212
import ChallengeList from './ChallengeList'
1313
import styles from './ChallengesComponent.module.scss'
@@ -53,6 +53,12 @@ const ChallengesComponent = ({
5353
const isReadOnly = checkReadOnlyRoles(auth.token) || loginUserRoleInProject === PROJECT_ROLES.READ
5454
const isAdminOrCopilot = checkAdminOrCopilot(auth.token, activeProject)
5555

56+
const projectStatus = activeProject && activeProject.status
57+
? activeProject.status.toUpperCase()
58+
: ''
59+
const isCompletedOrCancelled =
60+
projectStatus === CHALLENGE_STATUS.CANCELLED || projectStatus === CHALLENGE_STATUS.COMPLETED
61+
5662
useEffect(() => {
5763
const loggedInUser = auth.user
5864
const projectMembers = activeProject.members
@@ -94,7 +100,7 @@ const ChallengesComponent = ({
94100
className={styles.btnOutline}
95101
/>
96102
)}
97-
{(checkAdmin(auth.token) || checkManager(auth.token)) && (
103+
{(checkAdmin(auth.token) || checkManager(auth.token)) && !isCompletedOrCancelled && (
98104
<OutlineButton
99105
text='Request Copilot'
100106
type={'info'}

0 commit comments

Comments
 (0)