Skip to content

support for job descriptions #261

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

Merged
merged 10 commits into from
Nov 10, 2020
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules
_auto_doc_
.vscode
topcoder-react-lib-*.*.*.tgz
.idea
2 changes: 2 additions & 0 deletions __tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ Object {
"getReviewTypesInit": [Function],
"getSkillTagsDone": [Function],
"getSkillTagsInit": [Function],
"getTechnologiesDone": [Function],
"getTechnologiesInit": [Function],
"getTypesDone": [Function],
"getTypesInit": [Function],
},
Expand Down
2 changes: 2 additions & 0 deletions __tests__/actions/__snapshots__/lookup.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Object {
"getReviewTypesInit": [Function],
"getSkillTagsDone": [Function],
"getSkillTagsInit": [Function],
"getTechnologiesDone": [Function],
"getTechnologiesInit": [Function],
"getTypesDone": [Function],
"getTypesInit": [Function],
},
Expand Down
10 changes: 10 additions & 0 deletions __tests__/reducers/__snapshots__/lookup.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Object {
"status": "APPROVED",
},
],
"technologies": Array [],
"types": Array [],
}
`;
Expand Down Expand Up @@ -58,6 +59,7 @@ Object {
"status": "APPROVED",
},
],
"technologies": Array [],
"types": Array [],
}
`;
Expand All @@ -83,6 +85,7 @@ Object {
"status": "APPROVED",
},
],
"technologies": Array [],
"types": Array [],
}
`;
Expand All @@ -108,6 +111,7 @@ Object {
"status": "APPROVED",
},
],
"technologies": Array [],
"types": Array [],
}
`;
Expand All @@ -125,6 +129,7 @@ Object {
"oses": Array [],
"reviewTypes": Array [],
"skillTags": Array [],
"technologies": Array [],
"types": Array [],
}
`;
Expand Down Expand Up @@ -156,6 +161,7 @@ Object {
"status": "APPROVED",
},
],
"technologies": Array [],
"types": Array [],
}
`;
Expand Down Expand Up @@ -187,6 +193,7 @@ Object {
"status": "APPROVED",
},
],
"technologies": Array [],
"types": Array [],
}
`;
Expand All @@ -212,6 +219,7 @@ Object {
"status": "APPROVED",
},
],
"technologies": Array [],
"types": Array [],
}
`;
Expand All @@ -237,6 +245,7 @@ Object {
"status": "APPROVED",
},
],
"technologies": Array [],
"types": Array [],
}
`;
Expand All @@ -254,6 +263,7 @@ Object {
"oses": Array [],
"reviewTypes": Array [],
"skillTags": Array [],
"technologies": Array [],
"types": Array [],
}
`;
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff 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": "1000.25.7",
"version": "1000.25.8",
"dependencies": {
"auth0-js": "^6.8.4",
"config": "^3.2.0",
Expand Down
18 changes: 18 additions & 0 deletions src/actions/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,22 @@ function getAllCountriesDone(tokenV3) {
return getService(tokenV3).getAllCountries();
}

/**
* @static
* @desc Creates an action that signals beginning of getting all technologies.
* @return {Action}
*/
function getTechnologiesInit() {}

/**
* @static
* @desc Creates an action that gets all technologies.
* @return {Action}
*/
function getTechnologiesDone() {
return getService().getTechnologies();
}

export default createActions({
LOOKUP: {
GET_TYPES_INIT: getTypesInit,
Expand All @@ -191,5 +207,7 @@ export default createActions({
GET_REVIEW_TYPES_DONE: getReviewTypesDone,
GET_ALL_COUNTRIES_INIT: getAllCountriesInit,
GET_ALL_COUNTRIES_DONE: getAllCountriesDone,
GET_TECHNOLOGIES_INIT: getTechnologiesInit,
GET_TECHNOLOGIES_DONE: getTechnologiesDone,
},
});
22 changes: 22 additions & 0 deletions src/reducers/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,25 @@ function onGetAllCountriesDone(state, { payload, error }) {
});
}

/**
* Handles LOOKUP/GET_TECHNOLOGIES_DONE action.
* @param {Object} state
* @param {Object} action Payload will be JSON from api call
* @return {Object} New state
*/
function onGetTechnologiesDone(state, { payload, error }) {
if (error) {
logger.error('Failed to get technologies', payload);
return { ...state, loadingTechnologiesError: true };
}

return ({
...state,
loadingTechnologiesError: false,
technologies: payload,
});
}

/**
* Creates a new Lookup reducer with the specified initial state.
* @param {Object} initialState Optional. Initial state.
Expand All @@ -260,6 +279,8 @@ function create(initialState = {}) {
[a.getReviewTypesDone]: onGetReviewTypesDone,
[a.getAllCountriesInit]: state => state,
[a.getAllCountriesDone]: onGetAllCountriesDone,
[a.getTechnologiesInit]: state => state,
[a.getTechnologiesDone]: onGetTechnologiesDone,
}, _.defaults(initialState, {
skillTags: [],
countries: [],
Expand All @@ -273,6 +294,7 @@ function create(initialState = {}) {
osPage: 1,
hasMoreOses: false,
reviewTypes: [],
technologies: [],
}));
}

Expand Down
10 changes: 10 additions & 0 deletions src/services/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class LookupService {
constructor(tokenV3) {
this.private = {
api: getApi('V3', tokenV3),
apiV4: getApi('V4', tokenV3),
apiV5: getApi('V5', tokenV3),
tokenV3,
};
Expand Down Expand Up @@ -119,6 +120,15 @@ class LookupService {
}
return [];
}

/**
* Gets all technologies.
* @return {Promise} Resolves to the review types.
*/
async getTechnologies() {
const res = await this.private.apiV4.get('/technologies');
return getApiResponsePayload(res);
}
}

let lastInstance = null;
Expand Down
53 changes: 29 additions & 24 deletions src/services/user-traits.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@
* via API V3.
*/
import toCapitalCase from 'to-capital-case';
import { getApiResponsePayload } from '../utils/tc';
import { getApi } from './api';

/**
* Private. Handles given response from the member's traits API.
* @param {Object} response
* @return {Promise} On success resolves to the data fetched from the API.
*/
function handleApiResponse(response) {
if (!response.ok) throw new Error(response.statusText);
return response.json();
}

/**
* Service class.
*/
Expand All @@ -16,7 +25,7 @@ class UserTraitsService {
*/
constructor(tokenV3) {
this.private = {
api: getApi('V3', tokenV3),
api: getApi('V5', tokenV3),
tokenV3,
};
}
Expand All @@ -29,7 +38,7 @@ class UserTraitsService {
async getAllUserTraits(handle) {
// FIXME: Remove the .toLowerCase() when the API is fixed to ignore the case in the route params
const res = await this.private.api.get(`/members/${handle.toLowerCase()}/traits`);
return getApiResponsePayload(res);
return handleApiResponse(res);
}

/**
Expand All @@ -40,18 +49,17 @@ class UserTraitsService {
* @return {Promise} Resolves to the member traits.
*/
async addUserTrait(handle, traitId, data) {
const body = {
param: [{
const body = [{
traitId,
categoryName: toCapitalCase(traitId),
traits: {
traitId,
categoryName: toCapitalCase(traitId),
traits: {
data,
},
}],
};
data,
},
}];

const res = await this.private.api.postJson(`/members/${handle}/traits`, body);
return getApiResponsePayload(res);
return handleApiResponse(res);
}

/**
Expand All @@ -62,18 +70,16 @@ class UserTraitsService {
* @return {Promise} Resolves to the member traits.
*/
async updateUserTrait(handle, traitId, data) {
const body = {
param: [{
traitId,
categoryName: toCapitalCase(traitId),
traits: {
data,
},
}],
};
const body = [{
traitId,
categoryName: toCapitalCase(traitId),
traits: {
data,
},
}];

const res = await this.private.api.putJson(`/members/${handle}/traits`, body);
return getApiResponsePayload(res);
return handleApiResponse(res);
}

/**
Expand All @@ -83,8 +89,7 @@ class UserTraitsService {
* @return {Promise} Resolves to the member traits.
*/
async deleteUserTrait(handle, traitId) {
const res = await this.private.api.delete(`/members/${handle}/traits?traitIds=${traitId}`);
return getApiResponsePayload(res);
await this.private.api.delete(`/members/${handle}/traits?traitIds=${traitId}`);
}
}

Expand Down