Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tc academy certifications#347

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
luizrrodrigues merged 4 commits intodevelopfromtc-academy-certifications
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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
2 changes: 1 addition & 1 deletion.circleci/config.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ jobs:
- attach_workspace:
at: .
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run: npm publish
- run: npm publish --tag test-release
# dont change anything
workflows:
version: 2
Expand Down
9 changes: 9 additions & 0 deletions__tests__/__snapshots__/index.js.snap
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -206,6 +206,10 @@ Object {
"getCommunityStatsDone": [Function],
"getCommunityStatsInit": [Function],
},
"tcAcademy": Object {
"getTcaCertificationsDone": [Function],
"getTcaCertificationsInit": [Function],
},
"terms": Object {
"agreeTermDone": [Function],
"agreeTermInit": [Function],
Expand DownExpand Up@@ -288,6 +292,7 @@ Object {
"reviewOpportunity": [Function],
"settings": [Function],
"stats": [Function],
"tcAcademy": [Function],
"terms": [Function],
},
"services": Object {
Expand DownExpand Up@@ -354,6 +359,10 @@ Object {
"default": undefined,
"getService": [Function],
},
"tcAcademy": Object {
"default": undefined,
"getService": [Function],
},
"terms": Object {
"default": undefined,
"getService": [Function],
Expand Down
2 changes: 1 addition & 1 deletionpackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,7 @@
"lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .",
"test": "npm run lint && npm run jest"
},
"version": "1.2.7",
"version": "1000.29.6",
"dependencies": {
"auth0-js": "^6.8.4",
"config": "^3.2.0",
Expand Down
2 changes: 2 additions & 0 deletionssrc/actions/index.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@ import settingsActions from './settings';
import lookerActions from './looker';
import memberSearchActions from './member-search';
import notificationActions from './notifications';
import tcAcademyActions from './tc-academy';

export const actions = {
auth: authActions.auth,
Expand All@@ -34,6 +35,7 @@ export const actions = {
looker: lookerActions.looker,
memberSearch: memberSearchActions.memberSearch,
notifications: notificationActions.notifications,
tcAcademy: tcAcademyActions.tcAcademy,
};

export default undefined;
35 changes: 35 additions & 0 deletionssrc/actions/tc-academy.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
import { redux } from 'topcoder-react-utils';
import { getService } from 'services/tc-academy';

const tcAcademyService = getService();

/**
* @static
* @desc Creates an action that signals beginning of user tc-academy certifications loading.
* @return {Action}
*/
function getTcaCertificationsInit(userId) {
return { userId };
}

/**
* @static
* @desc Creates an action that loads user tc-academy certifications from API v2.
* @param {String} userId User id.
* @return {Action}
*/
async function getTcaCertificationsDone(userId) {
const res = await tcAcademyService.getCertifications(userId);

return {
userId,
certifications: res,
};
}

export default redux.createActions({
TC_ACADEMY: {
GET_TCA_CERTIFICATIONS_INIT: getTcaCertificationsInit,
GET_TCA_CERTIFICATIONS_DONE: getTcaCertificationsDone,
},
});
3 changes: 3 additions & 0 deletionssrc/reducers/index.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,6 +13,7 @@ import challenge, { factory as challengeFactory } from './challenge';
import profile, { factory as profileFactory } from './profile';
import members, { factory as membersFactory } from './members';
import notifications, { factory as notificationsFactory } from './notifications';
import tcAcademy, { factory as tcAcademyFactory } from './tc-academy';
import lookup, { factory as lookupFactory } from './lookup';
import memberTasks, { factory as memberTasksFactory } from './member-tasks';
import reviewOpportunity, { factory as reviewOpportunityFactory }
Expand DownExpand Up@@ -44,6 +45,7 @@ export function factory(options) {
looker: lookerFactory(options),
memberSearch: memberSearchFactory(options),
notifications: notificationsFactory(options),
tcAcademy: tcAcademyFactory(options),
});
}

Expand All@@ -65,4 +67,5 @@ export default ({
looker,
memberSearch,
notifications,
tcAcademy,
});
63 changes: 63 additions & 0 deletionssrc/reducers/tc-academy.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
/**
* Reducer for TC Academy
*/

import { handleActions } from 'redux-actions';
import actions from 'actions/tc-academy';

/**
* Handles TCACADEMY/GET_TCA_CERTIFICATIONS_INIT action.
* @param {Object} state
* @return {Object} New state
*/
function onGetTcaCertificationsInit(state) {
return {
...state,
certifications: [],
failed: false,
loading: true,
};
}

/**
* Handles TCACADEMY/GET_TCA_CERTIFICATIONS_DONE actions.
* @param {Object} state Previous state.
* @param {Object} action Action.
*/
function onGetTcaCertificationsDone(state, action) {
return {
...state,
certifications: [],
...(action.error ? {} : action.payload),
failed: action.error,
loading: false,
};
}

/**
* Creates a new challenges reducer with the specified initial state.
* @param {Object} initialState Optional. Initial state.
* @return challenges reducer.
*/
function create(initialState) {
const a = actions.tcAcademy;

return handleActions({
[a.getTcaCertificationsInit]: onGetTcaCertificationsInit,
[a.getTcaCertificationsDone]: onGetTcaCertificationsDone,
}, initialState || {});
}

/**
* Factory which creates a new reducer with its initial state tailored to the
* given options object, if specified (for server-side rendering). If options
* object is not specified, it creates just the default reducer. Accepted options are:
* @return {Promise}
* @resolves {Function(state, action): state} New reducer.
*/
export function factory() {
return Promise.resolve(create());
}

/* Default reducer with empty initial state. */
export default create();
2 changes: 2 additions & 0 deletionssrc/services/index.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@ import * as userTraits from './user-traits';
import * as submissions from './submissions';
import * as memberSearch from './member-search';
import * as notifications from './notifications';
import * as tcAcademy from './tc-academy';

export const services = {
api,
Expand All@@ -35,6 +36,7 @@ export const services = {
submissions,
memberSearch,
notifications,
tcAcademy,
};

export default undefined;
37 changes: 37 additions & 0 deletionssrc/services/tc-academy.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
import { getApi } from './api';

/**
* Topcoder Academy service class
*/
class TcAcademyService {
constructor() {
this.private = {
api: getApi('V5'),
};
}

/**
*
* @param {string} userId Get all user's certifications (completed)
* @returns
*/
getCertifications(userId) {
return this.private.api.get(`/learning-paths/completed-certifications/${userId}`)
.then(res => (res.ok ? res.json() : new Error(res.statusText)));
}
}

/**
* Returns a new or existing service instance.
* @return {TcAcademyService} Topcoder Academy service instance
*/
let lastInstance = null;
export function getService() {
if (!lastInstance) {
lastInstance = new TcAcademyService();
}
return lastInstance;
}

/* Using default export would be confusing in this case. */
export default undefined;

[8]ページ先頭

©2009-2025 Movatter.jp