Skip to content

Commit ac0b11d

Browse files
Merge pull request #23 from topcoder-platform/integration-v5-challenge-api
Integration v5 challenge api
2 parents a88ac03 + debbf90 commit ac0b11d

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

src/shared/components/challenge-detail/Header/index.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ export default function ChallengeHeader(props) {
6666
events,
6767
legacy,
6868
prizeSets,
69-
numberOfCheckpointsPrizes,
70-
topCheckPointPrize,
7169
reliabilityBonus,
7270
userDetails,
7371
numRegistrants,
@@ -83,6 +81,14 @@ export default function ChallengeHeader(props) {
8381
const { prizes } = prizeSets && prizeSets.length ? prizeSets[0] : [];
8482
const status = allPhases.length ? allPhases[0].name : '';
8583

84+
const checkpointPrizes = _.find(prizeSets, { type: 'checkpoint' });
85+
let numberOfCheckpointsPrizes = 0;
86+
let topCheckPointPrize = 0;
87+
if (!_.isEmpty(checkpointPrizes)) {
88+
numberOfCheckpointsPrizes = checkpointPrizes.prizes.length;
89+
topCheckPointPrize = checkpointPrizes.prizes[0].value;
90+
}
91+
8692
const phases = {};
8793
if (allPhases) {
8894
allPhases.forEach((phase) => {
@@ -483,8 +489,6 @@ ChallengeHeader.propTypes = {
483489
legacy: PT.shape({
484490
track: PT.any,
485491
}),
486-
numberOfCheckpointsPrizes: PT.any,
487-
topCheckPointPrize: PT.any,
488492
reliabilityBonus: PT.any,
489493
userDetails: PT.any,
490494
currentPhases: PT.any,

src/shared/components/challenge-detail/Specification/SideBar/index.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export default function SideBar({
172172
)
173173
}
174174
{
175-
screeningScorecardId && screeningScorecardId.length > 0
175+
screeningScorecardId > 0
176176
&& (
177177
<p styleName="link-like-paragraph">
178178
<a href={`${scorecardURL}${screeningScorecardId}`}>
@@ -182,6 +182,8 @@ export default function SideBar({
182182
)
183183
}
184184
{
185+
reviewScorecardId > 0 && !isDesign
186+
&& (
185187
<span styleName="link-like-paragraph tooltip-container">
186188
<a href={`${scorecardURL}${reviewScorecardId}`}>
187189
Review Scorecard
@@ -192,6 +194,7 @@ export default function SideBar({
192194
</div>
193195
</Tooltip>
194196
</span>
197+
)
195198
}
196199
</div>
197200
)

src/shared/containers/challenge-detail/index.jsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ class ChallengeDetailPageContainer extends React.Component {
166166
reviewTypes,
167167
getAllCountries,
168168
getReviewTypes,
169-
history,
170169
} = this.props;
171170

172171
if (
@@ -192,7 +191,7 @@ class ChallengeDetailPageContainer extends React.Component {
192191
&& !challenge.fetchedWithAuth)
193192

194193
) {
195-
loadChallengeDetails(auth, challengeId, history);
194+
loadChallengeDetails(auth, challengeId);
196195
}
197196

198197
if (!allCountries.length) {
@@ -219,8 +218,14 @@ class ChallengeDetailPageContainer extends React.Component {
219218
auth,
220219
challenge,
221220
loadingRecommendedChallengesUUID,
221+
history,
222222
} = this.props;
223223

224+
if (challenge.isLegacyChallenge && !history.location.pathname.includes(challenge.id)) {
225+
history.location.pathname = `/challenges/${challenge.id}`; // eslint-disable-line no-param-reassign
226+
history.push(history.location.pathname, history.state);
227+
}
228+
224229
const recommendedTechnology = getRecommendedTags(challenge);
225230
if (
226231
challenge
@@ -843,15 +848,12 @@ const mapDispatchToProps = (dispatch) => {
843848
dispatch(lookupActions.getReviewTypesInit());
844849
dispatch(lookupActions.getReviewTypesDone(tokenV3));
845850
},
846-
loadChallengeDetails: (tokens, challengeId, history) => {
851+
loadChallengeDetails: (tokens, challengeId) => {
847852
const a = actions.challenge;
848853
dispatch(a.getDetailsInit(challengeId));
849854
dispatch(a.getDetailsDone(challengeId, tokens.tokenV3, tokens.tokenV2))
850855
.then((res) => {
851856
const ch = res.payload;
852-
if (ch.isLegacyChallenge) {
853-
history.location.pathname = `/challenges/${ch.id}`; // eslint-disable-line no-param-reassign
854-
}
855857
if (ch.track === 'DESIGN') {
856858
const p = ch.allPhases || ch.phases || []
857859
.filter(x => x.name === 'Checkpoint Review');

0 commit comments

Comments
 (0)