Skip to content

Payment tool updates #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: payment-tool-develop-sync
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions __tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ Object {
"default": undefined,
"getService": [Function],
},
"resource": Object {
"default": undefined,
"getService": [Function],
},
"reviewOpportunities": Object {
"default": undefined,
"getReviewOpportunitiesService": [Function],
Expand Down
13 changes: 7 additions & 6 deletions __tests__/actions/auth.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
const MOCK_GROUPS_REQ_URL = 'https://api.topcoder-dev.com/v3/groups?memberId=12345&membershipType=user';
const MOCK_GROUPS_REQ_URL = 'https://api.topcoder-dev.com/v5/groups?memberId=12345&membershipType=user';
const MOCK_PROFILE_REQ_URL = 'https://api.topcoder-dev.com/v3/members/username12345';

jest.mock('isomorphic-fetch', () => jest.fn(url => Promise.resolve({
json: () => {
let content;
switch (url) {
case MOCK_GROUPS_REQ_URL: content = ['Group1', 'Group2']; break;
case MOCK_PROFILE_REQ_URL: content = { userId: 12345 }; break;
case MOCK_GROUPS_REQ_URL: content = ['Group1', 'Group2'];
return content;
case MOCK_PROFILE_REQ_URL: content = { userId: 12345 };
return {
result: { content, status: 200 },
};
default: throw new Error('Unexpected URL!');
}
return {
result: { content, status: 200 },
};
},
})));

Expand Down
2 changes: 2 additions & 0 deletions config/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module.exports = {
API: {
V2: 'https://api.topcoder-dev.com/v2',
V3: 'https://api.topcoder-dev.com/v3',
V4: 'https://api.topcoder-dev.com/v4',
V5: 'https://api.topcoder-dev.com/v5',
},
dummyConfigKey: 'Dummy config value',
};
1,445 changes: 0 additions & 1,445 deletions dist/dev/index.js

This file was deleted.

15,280 changes: 7,579 additions & 7,701 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/actions/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ function loadProfileDone(userTokenV3) {
if (!userTokenV3) return Promise.resolve(null);
const user = decodeToken(userTokenV3);
const api = getApi('V3', userTokenV3);
const apiV5 = getApi('V5', userTokenV3);
return Promise.all([
api.get(`/members/${user.handle}`)
.then(res => res.json()).then(res => (res.result.status === 200 ? res.result.content : {})),
api.get(`/groups?memberId=${user.userId}&membershipType=user`)
.then(res => res.json()).then(res => (res.result.status === 200 ? res.result.content : [])),
apiV5.get(`/groups?memberId=${user.userId}&membershipType=user`)
.then(res => res.json()).then(res => (res && res.length ? res : [])),
]).then(([profile, groups]) => ({ ...profile, groups }));
}

Expand Down
14 changes: 7 additions & 7 deletions src/actions/direct.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ function getUserProjectsInit(tokenV3) {
* @static
* @desc Creates an action that loads projects related to a user.
* @param {String} tokenV3 Topcoder auth token v3.
* @param {Boolean} hasActiveBillingAccount Optional. Defaults to false.
* Whether only projects with active billing accounts should be included
* into the results.
* @return {Action}
*/
async function getUserProjectsDone(tokenV3, hasActiveBillingAccount) {
const params = {};
if (hasActiveBillingAccount) params.hasActiveBillingAccount = true;
const projects = await getService(tokenV3).getUserProjects(params);
async function getUserProjectsDone(tokenV3) {
// Fetches Member's only Active projects
const projects = await getService(tokenV3).getUserProjects({
memberOnly: true,
sort: 'lastActivityAt desc',
status: 'active',
});
return { tokenV3, projects };
}

Expand Down
9 changes: 5 additions & 4 deletions src/actions/member-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ function getInit(uuid, pageNum) {
*/
function getDone(uuid, projectId, pageNum, tokenV3) {
return getService(tokenV3).getChallenges({
isTask: 1,
isTask: true,
projectId,
}, {
limit: PAGE_SIZE,
offset: pageNum * PAGE_SIZE,
sortBy: 'updated',
sortOrder: 'desc',
perPage: PAGE_SIZE,
page: pageNum + 1,
}).then(({ challenges, totalCount }) => ({
projectId,
tasks: challenges,
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/direct.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function onGetProjectDetailsDone(state, { error, payload }) {
logger.error('Failed to load project details', payload);
throw payload;
}
if (payload.project.projectId !== state.loadingProjectDetailsForId) {
if (payload.id !== state.loadingProjectDetailsForId) {
return state;
}
return {
Expand Down
Loading