|
7 | 7 | import _ from 'lodash';
|
8 | 8 | import { config } from 'topcoder-react-utils';
|
9 | 9 | import { createActions } from 'redux-actions';
|
| 10 | +import { decodeToken } from 'tc-accounts'; |
10 | 11 | import { getService as getChallengesService } from '../services/challenges';
|
11 | 12 | import { getService as getSubmissionService } from '../services/submissions';
|
12 | 13 | import { getService as getMemberService } from '../services/members';
|
@@ -103,16 +104,20 @@ function getSubmissionsInit(challengeId) {
|
103 | 104 | * @desc Creates an action that loads user's submissions to the specified
|
104 | 105 | * challenge.
|
105 | 106 | * @param {String} challengeId Challenge ID.
|
106 |
| - * @param {String} tokenV2 Topcoder auth token v2. |
| 107 | + * @param {String} tokenV3 Topcoder auth token v3. |
107 | 108 | * @return {Action}
|
108 | 109 | */
|
109 |
| -function getSubmissionsDone(challengeId, tokenV2) { |
110 |
| - return getApi('V2', tokenV2) |
111 |
| - .fetch(`/challenges/submissions/${challengeId}/mySubmissions`) |
112 |
| - .then(response => response.json()) |
113 |
| - .then(response => ({ |
| 110 | +function getSubmissionsDone(challengeId, tokenV3) { |
| 111 | + const user = decodeToken(tokenV3); |
| 112 | + const submissionsService = getSubmissionService(tokenV3); |
| 113 | + const filters = { |
| 114 | + challengeId, |
| 115 | + memberId: user.userId, |
| 116 | + }; |
| 117 | + return submissionsService.getSubmissions(filters) |
| 118 | + .then(submissions => ({ |
114 | 119 | challengeId: _.toString(challengeId),
|
115 |
| - submissions: response.submissions, |
| 120 | + submissions, |
116 | 121 | }))
|
117 | 122 | .catch((error) => {
|
118 | 123 | const err = { challengeId: _.toString(challengeId), error };
|
@@ -289,13 +294,13 @@ function fetchCheckpointsDone(tokenV2, challengeId) {
|
289 | 294 | response.checkpointResults[index].expanded = false;
|
290 | 295 | });
|
291 | 296 | return {
|
292 |
| - challengeId: Number(challengeId), |
| 297 | + challengeId: String(challengeId), |
293 | 298 | checkpoints: response,
|
294 | 299 | };
|
295 | 300 | })
|
296 | 301 | .catch(error => ({
|
297 | 302 | error,
|
298 |
| - challengeId: Number(challengeId), |
| 303 | + challengeId: String(challengeId), |
299 | 304 | }));
|
300 | 305 | }
|
301 | 306 |
|
|
0 commit comments