Skip to content

Commit 1909681

Browse files
Merge pull request topcoder-platform#261 from topcoder-platform/support_for_job_description
support for job descriptions
2 parents 3b8c6bd + 0f90892 commit 1909681

File tree

10 files changed

+96
-26
lines changed

10 files changed

+96
-26
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ node_modules
66
_auto_doc_
77
.vscode
88
topcoder-react-lib-*.*.*.tgz
9+
.idea

__tests__/__snapshots__/index.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ Object {
7272
"getReviewTypesInit": [Function],
7373
"getSkillTagsDone": [Function],
7474
"getSkillTagsInit": [Function],
75+
"getTechnologiesDone": [Function],
76+
"getTechnologiesInit": [Function],
7577
"getTypesDone": [Function],
7678
"getTypesInit": [Function],
7779
},

__tests__/actions/__snapshots__/lookup.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Object {
1717
"getReviewTypesInit": [Function],
1818
"getSkillTagsDone": [Function],
1919
"getSkillTagsInit": [Function],
20+
"getTechnologiesDone": [Function],
21+
"getTechnologiesInit": [Function],
2022
"getTypesDone": [Function],
2123
"getTypesInit": [Function],
2224
},

__tests__/reducers/__snapshots__/lookup.js.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Object {
2727
"status": "APPROVED",
2828
},
2929
],
30+
"technologies": Array [],
3031
"types": Array [],
3132
}
3233
`;
@@ -58,6 +59,7 @@ Object {
5859
"status": "APPROVED",
5960
},
6061
],
62+
"technologies": Array [],
6163
"types": Array [],
6264
}
6365
`;
@@ -83,6 +85,7 @@ Object {
8385
"status": "APPROVED",
8486
},
8587
],
88+
"technologies": Array [],
8689
"types": Array [],
8790
}
8891
`;
@@ -108,6 +111,7 @@ Object {
108111
"status": "APPROVED",
109112
},
110113
],
114+
"technologies": Array [],
111115
"types": Array [],
112116
}
113117
`;
@@ -125,6 +129,7 @@ Object {
125129
"oses": Array [],
126130
"reviewTypes": Array [],
127131
"skillTags": Array [],
132+
"technologies": Array [],
128133
"types": Array [],
129134
}
130135
`;
@@ -156,6 +161,7 @@ Object {
156161
"status": "APPROVED",
157162
},
158163
],
164+
"technologies": Array [],
159165
"types": Array [],
160166
}
161167
`;
@@ -187,6 +193,7 @@ Object {
187193
"status": "APPROVED",
188194
},
189195
],
196+
"technologies": Array [],
190197
"types": Array [],
191198
}
192199
`;
@@ -212,6 +219,7 @@ Object {
212219
"status": "APPROVED",
213220
},
214221
],
222+
"technologies": Array [],
215223
"types": Array [],
216224
}
217225
`;
@@ -237,6 +245,7 @@ Object {
237245
"status": "APPROVED",
238246
},
239247
],
248+
"technologies": Array [],
240249
"types": Array [],
241250
}
242251
`;
@@ -254,6 +263,7 @@ Object {
254263
"oses": Array [],
255264
"reviewTypes": Array [],
256265
"skillTags": Array [],
266+
"technologies": Array [],
257267
"types": Array [],
258268
}
259269
`;

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .",
3232
"test": "npm run lint && npm run jest"
3333
},
34-
"version": "1000.25.7",
34+
"version": "1000.25.8",
3535
"dependencies": {
3636
"auth0-js": "^6.8.4",
3737
"config": "^3.2.0",

src/actions/lookup.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,22 @@ function getAllCountriesDone(tokenV3) {
173173
return getService(tokenV3).getAllCountries();
174174
}
175175

176+
/**
177+
* @static
178+
* @desc Creates an action that signals beginning of getting all technologies.
179+
* @return {Action}
180+
*/
181+
function getTechnologiesInit() {}
182+
183+
/**
184+
* @static
185+
* @desc Creates an action that gets all technologies.
186+
* @return {Action}
187+
*/
188+
function getTechnologiesDone() {
189+
return getService().getTechnologies();
190+
}
191+
176192
export default createActions({
177193
LOOKUP: {
178194
GET_TYPES_INIT: getTypesInit,
@@ -191,5 +207,7 @@ export default createActions({
191207
GET_REVIEW_TYPES_DONE: getReviewTypesDone,
192208
GET_ALL_COUNTRIES_INIT: getAllCountriesInit,
193209
GET_ALL_COUNTRIES_DONE: getAllCountriesDone,
210+
GET_TECHNOLOGIES_INIT: getTechnologiesInit,
211+
GET_TECHNOLOGIES_DONE: getTechnologiesDone,
194212
},
195213
});

src/reducers/lookup.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,25 @@ function onGetAllCountriesDone(state, { payload, error }) {
236236
});
237237
}
238238

239+
/**
240+
* Handles LOOKUP/GET_TECHNOLOGIES_DONE action.
241+
* @param {Object} state
242+
* @param {Object} action Payload will be JSON from api call
243+
* @return {Object} New state
244+
*/
245+
function onGetTechnologiesDone(state, { payload, error }) {
246+
if (error) {
247+
logger.error('Failed to get technologies', payload);
248+
return { ...state, loadingTechnologiesError: true };
249+
}
250+
251+
return ({
252+
...state,
253+
loadingTechnologiesError: false,
254+
technologies: payload,
255+
});
256+
}
257+
239258
/**
240259
* Creates a new Lookup reducer with the specified initial state.
241260
* @param {Object} initialState Optional. Initial state.
@@ -260,6 +279,8 @@ function create(initialState = {}) {
260279
[a.getReviewTypesDone]: onGetReviewTypesDone,
261280
[a.getAllCountriesInit]: state => state,
262281
[a.getAllCountriesDone]: onGetAllCountriesDone,
282+
[a.getTechnologiesInit]: state => state,
283+
[a.getTechnologiesDone]: onGetTechnologiesDone,
263284
}, _.defaults(initialState, {
264285
skillTags: [],
265286
countries: [],
@@ -273,6 +294,7 @@ function create(initialState = {}) {
273294
osPage: 1,
274295
hasMoreOses: false,
275296
reviewTypes: [],
297+
technologies: [],
276298
}));
277299
}
278300

src/services/lookup.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class LookupService {
1515
constructor(tokenV3) {
1616
this.private = {
1717
api: getApi('V3', tokenV3),
18+
apiV4: getApi('V4', tokenV3),
1819
apiV5: getApi('V5', tokenV3),
1920
tokenV3,
2021
};
@@ -119,6 +120,15 @@ class LookupService {
119120
}
120121
return [];
121122
}
123+
124+
/**
125+
* Gets all technologies.
126+
* @return {Promise} Resolves to the review types.
127+
*/
128+
async getTechnologies() {
129+
const res = await this.private.apiV4.get('/technologies');
130+
return getApiResponsePayload(res);
131+
}
122132
}
123133

124134
let lastInstance = null;

src/services/user-traits.js

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,18 @@
44
* via API V3.
55
*/
66
import toCapitalCase from 'to-capital-case';
7-
import { getApiResponsePayload } from '../utils/tc';
87
import { getApi } from './api';
98

9+
/**
10+
* Private. Handles given response from the member's traits API.
11+
* @param {Object} response
12+
* @return {Promise} On success resolves to the data fetched from the API.
13+
*/
14+
function handleApiResponse(response) {
15+
if (!response.ok) throw new Error(response.statusText);
16+
return response.json();
17+
}
18+
1019
/**
1120
* Service class.
1221
*/
@@ -16,7 +25,7 @@ class UserTraitsService {
1625
*/
1726
constructor(tokenV3) {
1827
this.private = {
19-
api: getApi('V3', tokenV3),
28+
api: getApi('V5', tokenV3),
2029
tokenV3,
2130
};
2231
}
@@ -29,7 +38,7 @@ class UserTraitsService {
2938
async getAllUserTraits(handle) {
3039
// FIXME: Remove the .toLowerCase() when the API is fixed to ignore the case in the route params
3140
const res = await this.private.api.get(`/members/${handle.toLowerCase()}/traits`);
32-
return getApiResponsePayload(res);
41+
return handleApiResponse(res);
3342
}
3443

3544
/**
@@ -40,18 +49,17 @@ class UserTraitsService {
4049
* @return {Promise} Resolves to the member traits.
4150
*/
4251
async addUserTrait(handle, traitId, data) {
43-
const body = {
44-
param: [{
52+
const body = [{
53+
traitId,
54+
categoryName: toCapitalCase(traitId),
55+
traits: {
4556
traitId,
46-
categoryName: toCapitalCase(traitId),
47-
traits: {
48-
data,
49-
},
50-
}],
51-
};
57+
data,
58+
},
59+
}];
5260

5361
const res = await this.private.api.postJson(`/members/${handle}/traits`, body);
54-
return getApiResponsePayload(res);
62+
return handleApiResponse(res);
5563
}
5664

5765
/**
@@ -62,18 +70,16 @@ class UserTraitsService {
6270
* @return {Promise} Resolves to the member traits.
6371
*/
6472
async updateUserTrait(handle, traitId, data) {
65-
const body = {
66-
param: [{
67-
traitId,
68-
categoryName: toCapitalCase(traitId),
69-
traits: {
70-
data,
71-
},
72-
}],
73-
};
73+
const body = [{
74+
traitId,
75+
categoryName: toCapitalCase(traitId),
76+
traits: {
77+
data,
78+
},
79+
}];
7480

7581
const res = await this.private.api.putJson(`/members/${handle}/traits`, body);
76-
return getApiResponsePayload(res);
82+
return handleApiResponse(res);
7783
}
7884

7985
/**
@@ -83,8 +89,7 @@ class UserTraitsService {
8389
* @return {Promise} Resolves to the member traits.
8490
*/
8591
async deleteUserTrait(handle, traitId) {
86-
const res = await this.private.api.delete(`/members/${handle}/traits?traitIds=${traitId}`);
87-
return getApiResponsePayload(res);
92+
await this.private.api.delete(`/members/${handle}/traits?traitIds=${traitId}`);
8893
}
8994
}
9095

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy