Skip to content

Commit 5407a26

Browse files
Updated action getSubmissionsDone to use submissionsService
1 parent bed729f commit 5407a26

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/actions/challenge.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import _ from 'lodash';
88
import { config } from 'topcoder-react-utils';
99
import { createActions } from 'redux-actions';
10+
import { decodeToken } from 'tc-accounts';
1011
import { getService as getChallengesService } from '../services/challenges';
1112
import { getService as getSubmissionService } from '../services/submissions';
1213
import { getService as getMemberService } from '../services/members';
@@ -103,16 +104,20 @@ function getSubmissionsInit(challengeId) {
103104
* @desc Creates an action that loads user's submissions to the specified
104105
* challenge.
105106
* @param {String} challengeId Challenge ID.
106-
* @param {String} tokenV23 Topcoder auth token v3.
107+
* @param {String} tokenV3 Topcoder auth token v3.
107108
* @return {Action}
108109
*/
109110
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 => ({
114119
challengeId: _.toString(challengeId),
115-
submissions: response.submissions,
120+
submissions,
116121
}))
117122
.catch((error) => {
118123
const err = { challengeId: _.toString(challengeId), error };

0 commit comments

Comments
 (0)