From 35e60aa4f1e982fe2f50083a2f7c70516d67863c Mon Sep 17 00:00:00 2001 From: sr_jr Date: Sun, 31 May 2020 11:39:04 +0530 Subject: [PATCH 1/2] fix for issue #4435 --- .../challenge-detail/Specification/SideBar/index.jsx | 4 ++-- .../challenge-detail/Specification/index.jsx | 4 ++-- src/shared/containers/challenge-detail/index.jsx | 11 +++++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/shared/components/challenge-detail/Specification/SideBar/index.jsx b/src/shared/components/challenge-detail/Specification/SideBar/index.jsx index f62c684c93..2d92451145 100644 --- a/src/shared/components/challenge-detail/Specification/SideBar/index.jsx +++ b/src/shared/components/challenge-detail/Specification/SideBar/index.jsx @@ -348,7 +348,7 @@ SideBar.defaultProps = { environment: '', codeRepo: '', isMM: false, - metadata: [], + metadata: {}, reviewScorecardId: '', screeningScorecardId: '', }; @@ -370,7 +370,7 @@ SideBar.propTypes = { environment: PT.string, codeRepo: PT.string, isMM: PT.bool, - metadata: PT.arrayOf(PT.shape()), + metadata: PT.shape(), reviewScorecardId: PT.string, screeningScorecardId: PT.string, }; diff --git a/src/shared/components/challenge-detail/Specification/index.jsx b/src/shared/components/challenge-detail/Specification/index.jsx index 933ad7d258..ef11076c1c 100644 --- a/src/shared/components/challenge-detail/Specification/index.jsx +++ b/src/shared/components/challenge-detail/Specification/index.jsx @@ -436,7 +436,7 @@ ChallengeDetailsView.defaultProps = { finalSubmissionGuidelines: '', environment: '', codeRepo: '', - metadata: [], + metadata: {}, reviewScorecardId: '', screeningScorecardId: '', }, @@ -467,7 +467,7 @@ ChallengeDetailsView.propTypes = { userDetails: PT.shape({ roles: PT.arrayOf(PT.string).isRequired, }), - metadata: PT.arrayOf(PT.shape()), + metadata: PT.shape(), }), challengesUrl: PT.string.isRequired, communitiesList: PT.arrayOf(PT.shape({ diff --git a/src/shared/containers/challenge-detail/index.jsx b/src/shared/containers/challenge-detail/index.jsx index c4524be1ad..35ee190fca 100644 --- a/src/shared/containers/challenge-detail/index.jsx +++ b/src/shared/containers/challenge-detail/index.jsx @@ -191,7 +191,7 @@ class ChallengeDetailPageContainer extends React.Component { && !challenge.fetchedWithAuth) ) { - loadChallengeDetails(auth, challengeId); + loadChallengeDetails(auth, challengeId, this.props.history); } if (!allCountries.length) { @@ -841,12 +841,19 @@ const mapDispatchToProps = (dispatch) => { dispatch(lookupActions.getReviewTypesInit()); dispatch(lookupActions.getReviewTypesDone(tokenV3)); }, - loadChallengeDetails: (tokens, challengeId) => { + loadChallengeDetails: (tokens, challengeId, history) => { const a = actions.challenge; dispatch(a.getDetailsInit(challengeId)); dispatch(a.getDetailsDone(challengeId, tokens.tokenV3, tokens.tokenV2)) .then((res) => { const ch = res.payload; + console.log(`found challenge details: ${JSON.stringify(ch)}`); + if (ch.isLegacyChallenge) { + console.log(`redirecting to /challenges/${ch.id}`); + console.log(`history ${JSON.stringify(history)}`); + // history.push(`/challenges/${ch.id}`); + // history.pushState({}, null, `/challenges/${ch.id}`); + } if (ch.track === 'DESIGN') { const p = ch.allPhases || ch.phases || [] .filter(x => x.name === 'Checkpoint Review'); From b0f737ecbd3153fd0d663fdaf84d5125a73c4a24 Mon Sep 17 00:00:00 2001 From: sr_jr Date: Sun, 31 May 2020 14:56:26 +0530 Subject: [PATCH 2/2] fix for issue #4435 --- src/shared/containers/challenge-detail/index.jsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/shared/containers/challenge-detail/index.jsx b/src/shared/containers/challenge-detail/index.jsx index 35ee190fca..1e9945ed32 100644 --- a/src/shared/containers/challenge-detail/index.jsx +++ b/src/shared/containers/challenge-detail/index.jsx @@ -166,6 +166,7 @@ class ChallengeDetailPageContainer extends React.Component { reviewTypes, getAllCountries, getReviewTypes, + history, } = this.props; if ( @@ -191,7 +192,7 @@ class ChallengeDetailPageContainer extends React.Component { && !challenge.fetchedWithAuth) ) { - loadChallengeDetails(auth, challengeId, this.props.history); + loadChallengeDetails(auth, challengeId, history); } if (!allCountries.length) { @@ -706,6 +707,7 @@ ChallengeDetailPageContainer.propTypes = { expandedTags: PT.arrayOf(PT.number).isRequired, expandTag: PT.func.isRequired, loadingRecommendedChallengesUUID: PT.string.isRequired, + history: PT.shape().isRequired, }; function mapStateToProps(state, props) { @@ -847,12 +849,8 @@ const mapDispatchToProps = (dispatch) => { dispatch(a.getDetailsDone(challengeId, tokens.tokenV3, tokens.tokenV2)) .then((res) => { const ch = res.payload; - console.log(`found challenge details: ${JSON.stringify(ch)}`); if (ch.isLegacyChallenge) { - console.log(`redirecting to /challenges/${ch.id}`); - console.log(`history ${JSON.stringify(history)}`); - // history.push(`/challenges/${ch.id}`); - // history.pushState({}, null, `/challenges/${ch.id}`); + history.location.pathname = `/challenges/${ch.id}`; // eslint-disable-line no-param-reassign } if (ch.track === 'DESIGN') { const p = ch.allPhases || ch.phases || []