Skip to content

fix:issue-986 #1028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/actions/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
fetchResourceRoles,
fetchChallengeTimelines,
fetchChallengeTracks,
fetchGroupDetail,
updateChallenge,
patchChallenge,
createChallenge as createChallengeAPI,
Expand Down Expand Up @@ -182,6 +183,14 @@ export function loadChallengeDetails (projectId, challengeId) {
}
}

/**
* Loads group details
*/
export function loadGroupDetails (groupIds) {
const promiseAll = groupIds.map(id => fetchGroupDetail(id))
return Promise.all(promiseAll)
}

/**
* Update challenge details
*
Expand Down
17 changes: 15 additions & 2 deletions src/components/ChallengeEditor/ChallengeView/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import React, { useState, useEffect } from 'react'
import _ from 'lodash'
import { Helmet } from 'react-helmet'
import PropTypes from 'prop-types'
Expand All @@ -21,6 +21,7 @@ import PhaseInput from '../../PhaseInput'
import LegacyLinks from '../../LegacyLinks'
import AssignedMemberField from '../AssignedMember-Field'
import { getResourceRoleByName } from '../../../util/tc'
import { loadGroupDetails } from '../../../actions/challenges'
import Tooltip from '../../Tooltip'
import { MESSAGE, REVIEW_TYPES } from '../../../config/constants'

Expand All @@ -40,6 +41,18 @@ const ChallengeView = ({
const challengeTrack = _.find(metadata.challengeTracks, { id: challenge.trackId })

const [openAdvanceSettings, setOpenAdvanceSettings] = useState(false)
const [groups, setGroups] = useState('')

useEffect(() => {
if (challenge.groups && challenge.groups.length > 0) {
loadGroupDetails(challenge.groups).then(res => {
const groups = _.map(res, 'name').join(', ')
setGroups(groups)
})
} else {
setGroups('')
}
}, [challenge.groups])

const getResourceFromProps = (name) => {
const { resourceRoles } = metadata
Expand Down Expand Up @@ -167,7 +180,7 @@ const ChallengeView = ({
</div>
{openAdvanceSettings && (<div className={cn(styles.row, styles.topRow)}>
<div className={styles.col}>
<span><span className={styles.fieldTitle}>Groups:</span> {challenge.groups ? challenge.groups.join(', ') : ''}</span>
<span><span className={styles.fieldTitle}>Groups:</span> {groups}</span>
</div>
</div>)}
{
Expand Down
11 changes: 11 additions & 0 deletions src/services/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ export async function fetchGroups (filters) {
return _.get(response, 'data', [])
}

/**
* Api request for fetching Group Detail
*
* @param groupId
* @returns {Promise<*>}
*/
export async function fetchGroupDetail (id) {
const response = await axiosInstance.get(`${GROUPS_API_URL}/${id}`)
return _.get(response, 'data', [])
}

/**
* Api request for fetching timeline templates
* @returns {Promise<*>}
Expand Down