From 5aa0fdf97846bd83e83ed3bf14306a98f294f066 Mon Sep 17 00:00:00 2001 From: Luiz Ricardo Rodrigues Date: Tue, 10 Nov 2020 07:49:37 -0300 Subject: [PATCH] Revert "support for job descriptions" --- .gitignore | 1 - __tests__/__snapshots__/index.js.snap | 2 - .../actions/__snapshots__/lookup.js.snap | 2 - .../reducers/__snapshots__/lookup.js.snap | 10 ---- package-lock.json | 2 +- package.json | 2 +- src/actions/lookup.js | 18 ------- src/reducers/lookup.js | 22 -------- src/services/lookup.js | 10 ---- src/services/user-traits.js | 53 +++++++++---------- 10 files changed, 26 insertions(+), 96 deletions(-) diff --git a/.gitignore b/.gitignore index 62753454..27fb5f91 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,3 @@ node_modules _auto_doc_ .vscode topcoder-react-lib-*.*.*.tgz -.idea diff --git a/__tests__/__snapshots__/index.js.snap b/__tests__/__snapshots__/index.js.snap index 1b73c5a3..02658e98 100644 --- a/__tests__/__snapshots__/index.js.snap +++ b/__tests__/__snapshots__/index.js.snap @@ -72,8 +72,6 @@ Object { "getReviewTypesInit": [Function], "getSkillTagsDone": [Function], "getSkillTagsInit": [Function], - "getTechnologiesDone": [Function], - "getTechnologiesInit": [Function], "getTypesDone": [Function], "getTypesInit": [Function], }, diff --git a/__tests__/actions/__snapshots__/lookup.js.snap b/__tests__/actions/__snapshots__/lookup.js.snap index 261bac2c..5061adee 100644 --- a/__tests__/actions/__snapshots__/lookup.js.snap +++ b/__tests__/actions/__snapshots__/lookup.js.snap @@ -17,8 +17,6 @@ Object { "getReviewTypesInit": [Function], "getSkillTagsDone": [Function], "getSkillTagsInit": [Function], - "getTechnologiesDone": [Function], - "getTechnologiesInit": [Function], "getTypesDone": [Function], "getTypesInit": [Function], }, diff --git a/__tests__/reducers/__snapshots__/lookup.js.snap b/__tests__/reducers/__snapshots__/lookup.js.snap index 6b1a6d45..91055596 100644 --- a/__tests__/reducers/__snapshots__/lookup.js.snap +++ b/__tests__/reducers/__snapshots__/lookup.js.snap @@ -27,7 +27,6 @@ Object { "status": "APPROVED", }, ], - "technologies": Array [], "types": Array [], } `; @@ -59,7 +58,6 @@ Object { "status": "APPROVED", }, ], - "technologies": Array [], "types": Array [], } `; @@ -85,7 +83,6 @@ Object { "status": "APPROVED", }, ], - "technologies": Array [], "types": Array [], } `; @@ -111,7 +108,6 @@ Object { "status": "APPROVED", }, ], - "technologies": Array [], "types": Array [], } `; @@ -129,7 +125,6 @@ Object { "oses": Array [], "reviewTypes": Array [], "skillTags": Array [], - "technologies": Array [], "types": Array [], } `; @@ -161,7 +156,6 @@ Object { "status": "APPROVED", }, ], - "technologies": Array [], "types": Array [], } `; @@ -193,7 +187,6 @@ Object { "status": "APPROVED", }, ], - "technologies": Array [], "types": Array [], } `; @@ -219,7 +212,6 @@ Object { "status": "APPROVED", }, ], - "technologies": Array [], "types": Array [], } `; @@ -245,7 +237,6 @@ Object { "status": "APPROVED", }, ], - "technologies": Array [], "types": Array [], } `; @@ -263,7 +254,6 @@ Object { "oses": Array [], "reviewTypes": Array [], "skillTags": Array [], - "technologies": Array [], "types": Array [], } `; diff --git a/package-lock.json b/package-lock.json index 86a4b827..076542d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31730,4 +31730,4 @@ } } } -} \ No newline at end of file +} diff --git a/package.json b/package.json index fdd37223..11f16853 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.25.8", + "version": "1000.25.7", "dependencies": { "auth0-js": "^6.8.4", "config": "^3.2.0", diff --git a/src/actions/lookup.js b/src/actions/lookup.js index f4c191d1..753e2472 100644 --- a/src/actions/lookup.js +++ b/src/actions/lookup.js @@ -173,22 +173,6 @@ 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, @@ -207,7 +191,5 @@ 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, }, }); diff --git a/src/reducers/lookup.js b/src/reducers/lookup.js index 2e892d1f..e887ad39 100644 --- a/src/reducers/lookup.js +++ b/src/reducers/lookup.js @@ -236,25 +236,6 @@ 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. @@ -279,8 +260,6 @@ function create(initialState = {}) { [a.getReviewTypesDone]: onGetReviewTypesDone, [a.getAllCountriesInit]: state => state, [a.getAllCountriesDone]: onGetAllCountriesDone, - [a.getTechnologiesInit]: state => state, - [a.getTechnologiesDone]: onGetTechnologiesDone, }, _.defaults(initialState, { skillTags: [], countries: [], @@ -294,7 +273,6 @@ function create(initialState = {}) { osPage: 1, hasMoreOses: false, reviewTypes: [], - technologies: [], })); } diff --git a/src/services/lookup.js b/src/services/lookup.js index 93f0c005..cd2b99e7 100644 --- a/src/services/lookup.js +++ b/src/services/lookup.js @@ -15,7 +15,6 @@ class LookupService { constructor(tokenV3) { this.private = { api: getApi('V3', tokenV3), - apiV4: getApi('V4', tokenV3), apiV5: getApi('V5', tokenV3), tokenV3, }; @@ -120,15 +119,6 @@ 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; diff --git a/src/services/user-traits.js b/src/services/user-traits.js index d3a30415..c1d71b71 100644 --- a/src/services/user-traits.js +++ b/src/services/user-traits.js @@ -4,18 +4,9 @@ * 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. */ @@ -25,7 +16,7 @@ class UserTraitsService { */ constructor(tokenV3) { this.private = { - api: getApi('V5', tokenV3), + api: getApi('V3', tokenV3), tokenV3, }; } @@ -38,7 +29,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 handleApiResponse(res); + return getApiResponsePayload(res); } /** @@ -49,17 +40,18 @@ class UserTraitsService { * @return {Promise} Resolves to the member traits. */ async addUserTrait(handle, traitId, data) { - const body = [{ - traitId, - categoryName: toCapitalCase(traitId), - traits: { + const body = { + param: [{ traitId, - data, - }, - }]; + categoryName: toCapitalCase(traitId), + traits: { + data, + }, + }], + }; const res = await this.private.api.postJson(`/members/${handle}/traits`, body); - return handleApiResponse(res); + return getApiResponsePayload(res); } /** @@ -70,16 +62,18 @@ class UserTraitsService { * @return {Promise} Resolves to the member traits. */ async updateUserTrait(handle, traitId, data) { - const body = [{ - traitId, - categoryName: toCapitalCase(traitId), - traits: { - data, - }, - }]; + const body = { + param: [{ + traitId, + categoryName: toCapitalCase(traitId), + traits: { + data, + }, + }], + }; const res = await this.private.api.putJson(`/members/${handle}/traits`, body); - return handleApiResponse(res); + return getApiResponsePayload(res); } /** @@ -89,7 +83,8 @@ class UserTraitsService { * @return {Promise} Resolves to the member traits. */ async deleteUserTrait(handle, traitId) { - await this.private.api.delete(`/members/${handle}/traits?traitIds=${traitId}`); + const res = await this.private.api.delete(`/members/${handle}/traits?traitIds=${traitId}`); + return getApiResponsePayload(res); } }