@@ -30,6 +30,8 @@ import {
3030 replaceResourceInRole
3131} from '../../actions/challenges'
3232
33+ import { loadProject } from '../../actions/projects'
34+
3335import { connect } from 'react-redux'
3436import { SUBMITTER_ROLE_UUID , MESSAGE } from '../../config/constants'
3537import { patchChallenge } from '../../services/challenges'
@@ -74,7 +76,8 @@ class ChallengeEditor extends Component {
7476 loadGroups,
7577 loadResourceRoles,
7678 loadChallengeDetails,
77- loadResources
79+ loadResources,
80+ loadProject
7881 } = this . props
7982 loadTimelineTemplates ( )
8083 loadChallengePhases ( )
@@ -85,6 +88,7 @@ class ChallengeEditor extends Component {
8588 // loadChallengeTerms()
8689 loadGroups ( )
8790 loadResourceRoles ( )
91+ this . fetchProjectDetails ( match , loadProject )
8892 this . fetchChallengeDetails ( match , loadChallengeDetails , loadResources )
8993
9094 // this.unlisten = this.props.history.listen(() => {
@@ -112,6 +116,14 @@ class ChallengeEditor extends Component {
112116 }
113117 }
114118
119+ async fetchProjectDetails ( newMatch , loadProject ) {
120+ let projectId = _ . get ( newMatch . params , 'projectId' , null )
121+ projectId = projectId ? parseInt ( projectId ) : null
122+ if ( projectId ) {
123+ await loadProject ( projectId )
124+ }
125+ }
126+
115127 async fetchChallengeDetails ( newMatch , loadChallengeDetails , loadResources ) {
116128 let projectId = _ . get ( newMatch . params , 'projectId' , null )
117129 projectId = projectId ? parseInt ( projectId ) : null
@@ -413,7 +425,8 @@ ChallengeEditor.propTypes = {
413425 partiallyUpdateChallengeDetails : PropTypes . func . isRequired ,
414426 createChallenge : PropTypes . func . isRequired ,
415427 deleteChallenge : PropTypes . func . isRequired ,
416- replaceResourceInRole : PropTypes . func
428+ replaceResourceInRole : PropTypes . func ,
429+ loadProject : PropTypes . func
417430 // members: PropTypes.arrayOf(PropTypes.shape())
418431}
419432
@@ -450,7 +463,8 @@ const mapDispatchToProps = {
450463 partiallyUpdateChallengeDetails,
451464 deleteChallenge,
452465 createChallenge,
453- replaceResourceInRole
466+ replaceResourceInRole,
467+ loadProject
454468}
455469
456470export default withRouter ( connect ( mapStateToProps , mapDispatchToProps ) ( ChallengeEditor ) )
0 commit comments