diff --git a/docs/actions.challenge.md b/docs/actions.challenge.md index 3305792..37d909c 100644 --- a/docs/actions.challenge.md +++ b/docs/actions.challenge.md @@ -16,7 +16,7 @@ Actions related to Topcoder challenges APIs. * [.unregisterInit()](#module_actions.challenge.unregisterInit) ⇒ Action * [.unregisterDone(auth, challengeId)](#module_actions.challenge.unregisterDone) ⇒ Action * [.loadResultsInit(challengeId)](#module_actions.challenge.loadResultsInit) ⇒ Action - * [.loadResultsDone(auth, challengeId, type)](#module_actions.challenge.loadResultsDone) ⇒ Action + * [.loadResultsDone(challengeId, tokenV3)](#module_actions.challenge.loadResultsDone) ⇒ Action * [.fetchCheckpointsInit()](#module_actions.challenge.fetchCheckpointsInit) ⇒ Action * [.fetchCheckpointsDone(tokenV2, challengeId)](#module_actions.challenge.fetchCheckpointsDone) * [.toggleCheckpointFeedback(id, open)](#module_actions.challenge.toggleCheckpointFeedback) ⇒ Action @@ -144,18 +144,15 @@ Creates an action that signals beginning of challenge results loading. -### actions.challenge.loadResultsDone(auth, challengeId, type) ⇒ Action +### actions.challenge.loadResultsDone(challengeId, tokenV3) ⇒ Action Creates an action that loads challenge results. -**Kind**: static method of [actions.challenge](#module_actions.challenge) +**Kind**: static method of [actions.challenge](#module_actions.challenge) | Param | Type | Description | | --- | --- | --- | -| auth | Object | Object that holds Topcoder auth tokens. | -| [auth.tokenV2] | String | v2 token. | -| [auth.tokenV3] | String | v3 token. | | challengeId | Number \| String | Challenge ID. Should match the one passed in the previous [loadResultsInit](#module_actions.challenge.loadResultsInit) call. | -| type | String | Challenge type. | +| tokenV3 | String | Topcoder v3 auth token. | diff --git a/package.json b/package.json index 8d772c8..c76d4f7 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .", "test": "npm run lint && npm run jest" }, - "version": "1.2.13", + "version": "1.2.14", "dependencies": { "auth0-js": "^6.8.4", "config": "^3.2.0", diff --git a/src/actions/challenge.js b/src/actions/challenge.js index 9a1c048..ca0684b 100644 --- a/src/actions/challenge.js +++ b/src/actions/challenge.js @@ -239,22 +239,16 @@ function loadResultsInit(challengeId) { /** * @static * @desc Creates an action that loads challenge results. - * @param {Object} auth Object that holds Topcoder auth tokens. - * @param {String} [auth.tokenV2] v2 token. - * @param {String} [auth.tokenV3] v3 token. - * @param {Number|String} challengeId Challenge ID. Should match the one passed - * in the previous {@link module:actions.challenge.loadResultsInit} call. - * @param {String} type Challenge type. + * @param {String} challengeId The challenge id + * @param {String} tokenV3 Topcoder auth token v3. * @return {Action} */ -function loadResultsDone(auth, challengeId, type) { - return getApi('V2') - .fetch(`/${type}/challenges/result/${challengeId}`) - .then(response => response.json()) - .then(response => ({ - challengeId: _.toString(challengeId), - results: response.results, - })); +function loadResultsDone(challengeId, tokenV3) { + const service = getChallengesService(tokenV3); + return service.getChallengeDetails(challengeId).then(response => ({ + challengeId, + results: response.winners, + })); } /** diff --git a/src/reducers/challenge.js b/src/reducers/challenge.js index d6df61d..c31c9e6 100644 --- a/src/reducers/challenge.js +++ b/src/reducers/challenge.js @@ -520,7 +520,7 @@ export function factory(options = {}) { } const resultsPromise = challengeDetails.status === 'Completed' ? ( redux.resolveAction( - actions.challenge.loadResultsDone(tokens, challengeId, track.toLowerCase()), + actions.challenge.loadResultsDone(challengeId, tokens.tokenV3), ) ) : null; return Promise.all([res, checkpointsPromise, resultsPromise]);