|
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} tokenV23 Topcoder auth token v3. |
| 107 | + * @param {String} tokenV3 Topcoder auth token v3. |
107 | 108 | * @return {Action}
|
108 | 109 | */
|
109 | 110 | function getSubmissionsDone(challengeId, tokenV3) {
|
110 |
| - return getApi('V5', tokenV3) |
111 |
| - .fetch(`/submissions?challengeId=${challengeId}`) |
112 |
| - .then(response => response.json()) |
113 |
| - .then(response => ({ |
| 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 };
|
|
0 commit comments