diff --git a/package.json b/package.json index 6559a5cf..16989194 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": "1000.19.44", + "version": "1000.19.45", "dependencies": { "auth0-js": "^6.8.4", "config": "^3.2.0", diff --git a/src/reducers/challenge.js b/src/reducers/challenge.js index 05bb9bc9..e91c4f53 100644 --- a/src/reducers/challenge.js +++ b/src/reducers/challenge.js @@ -18,6 +18,8 @@ import { fireErrorMessage } from '../utils/errors'; import mySubmissionsManagement from './my-submissions-management'; +import { COMPETITION_TRACKS } from '../utils/tc'; + /** * Handles CHALLENGE/GET_DETAILS_INIT action. * @param {Object} state @@ -469,7 +471,7 @@ export function factory(options = {}) { const challengeDetails = _.get(res, 'payload', {}); const track = _.get(challengeDetails, 'legacy.track', ''); let checkpointsPromise = null; - if (track === 'DESIGN') { + if (track === COMPETITION_TRACKS.DESIGN) { const p = _.get(challengeDetails, 'phases', []) .filter(x => x.name === 'Checkpoint Review'); if (p.length && !p[0].isOpen) { diff --git a/src/services/challenges.js b/src/services/challenges.js index f24bdf5e..d0a298ae 100644 --- a/src/services/challenges.js +++ b/src/services/challenges.js @@ -407,7 +407,9 @@ class ChallengesService { .then(checkErrorV5).then(res => res.result); /* API will return all roles to currentUser, so need to filter in FE */ - registrants = _.filter(registrants, r => r.roleId === roleId); + if (roleId) { + registrants = _.filter(registrants, r => r.roleId === roleId); + } return registrants || []; } @@ -636,7 +638,7 @@ class ChallengesService { let contentType; let url; - if (track === 'DESIGN') { + if (track === COMPETITION_TRACKS.DESIGN) { ({ api } = this.private); contentType = 'application/json'; url = '/submissions/'; // The submission info is contained entirely in the JSON body @@ -654,7 +656,7 @@ class ChallengesService { }, onProgress).then((res) => { const jres = JSON.parse(res); // Return result for Develop submission - if (track === 'DEVELOP') { + if (track === COMPETITION_TRACKS.DEVELOP) { return jres; } // Design Submission requires an extra "Processing" POST diff --git a/src/services/members.js b/src/services/members.js index 7716c91d..a5b32a51 100644 --- a/src/services/members.js +++ b/src/services/members.js @@ -7,6 +7,7 @@ /* global XMLHttpRequest */ import _ from 'lodash'; import qs from 'qs'; +import { decodeToken } from 'tc-accounts'; import logger from '../utils/logger'; import { getApiResponsePayload } from '../utils/tc'; import { getApi } from './api'; @@ -329,7 +330,8 @@ class MembersService { * @param {Array} challengeId the challenge id */ async getChallengeResources(challengeId) { - const url = `/resources?challengeId=${challengeId}`; + const user = decodeToken(this.private.tokenV3); + const url = `/resources?challengeId=${challengeId}&memberId=${user.userId}`; let res = null; try { @@ -346,14 +348,14 @@ class MembersService { * @param {Array} memberId the member id */ async getUserResources(memberId) { - const url = `/resources/${memberId}/challenges`; + const url = `/challenges?status=Active&memberId=${memberId}`; const res = await this.private.apiV5.get(url); const challenges = await res.json(); const roles = await this.getResourceRoles(); const calls = []; challenges.forEach(async (ch) => { - calls.push(this.getChallengeResources(ch)); + calls.push(this.getChallengeResources(ch.id)); }); return Promise.all(calls).then((resources) => { diff --git a/src/utils/challenge/filter.js b/src/utils/challenge/filter.js index 36e91e6f..263c3132 100644 --- a/src/utils/challenge/filter.js +++ b/src/utils/challenge/filter.js @@ -89,7 +89,7 @@ function filterByRegistrationOpen(challenge, state) { if (!registrationPhase || !registrationPhase.isOpen) { return false; } - if (challenge.track === 'DESIGN') { + if (challenge.track === COMPETITION_TRACKS.DESIGN) { const checkpointPhase = challengePhases.find(item => item.name === 'Checkpoint Submission')[0]; return !checkpointPhase || !checkpointPhase.isOpen; }