Skip to content

Commit 6ab57cc

Browse files
fix challenge detail screen
1 parent d89ff66 commit 6ab57cc

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/services/challenges.js

+19-2
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,22 @@ class ChallengesService {
186186
},
187187
};
188188
};
189+
190+
const getChallengeDetails = async (
191+
endpoint,
192+
legacyInfo,
193+
) => {
194+
let query = '';
195+
if (legacyInfo) {
196+
query = `legacyId=${legacyInfo.legacyId}`;
197+
}
198+
const url = `${endpoint}?${query}`;
199+
const res = await this.private.apiV5.get(url).then(checkErrorV5);
200+
return {
201+
challenges: res.result || [],
202+
};
203+
};
204+
189205
/**
190206
* Private function being re-used in all methods related to getting
191207
* challenges. It handles query-related arguments in the uniform way:
@@ -221,6 +237,7 @@ class ChallengesService {
221237
apiV2: getApi('V2', tokenV2),
222238
apiV3: getApi('V3', tokenV3),
223239
getChallenges,
240+
getChallengeDetails,
224241
getMemberChallenges,
225242
tokenV2,
226243
tokenV3,
@@ -359,10 +376,10 @@ class ChallengesService {
359376
// condition based on ROUTE used for Review Opportunities, change if needed
360377
if (/^[\d]{5,8}$/.test(challengeId)) {
361378
isLegacyChallenge = true;
362-
challenge = await this.private.getChallenges('/challenges/', { legacyId: challengeId })
379+
challenge = await this.private.getChallengeDetails('/challenges/', { legacyId: challengeId })
363380
.then(res => res.challenges[0]);
364381
} else {
365-
challenge = await this.private.getChallenges(`/challenges/${challengeId}`)
382+
challenge = await this.private.getChallengeDetails(`/challenges/${challengeId}`)
366383
.then(res => res.challenges);
367384
}
368385

0 commit comments

Comments
 (0)