From 64280e11d52a7240e7c23f8fa645089ff9760444 Mon Sep 17 00:00:00 2001 From: sr_jr Date: Tue, 26 May 2020 02:01:16 +0530 Subject: [PATCH 1/2] fix for issue #4410 --- src/services/reviewOpportunities.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/services/reviewOpportunities.js b/src/services/reviewOpportunities.js index 6c37bf12..42ad4844 100644 --- a/src/services/reviewOpportunities.js +++ b/src/services/reviewOpportunities.js @@ -3,8 +3,25 @@ * @desc This module provides a service for retrieving Review Opportunities and * submitting applications. */ +import _ from 'lodash'; import { getApi } from './api'; +/** + * Sync the fields of V3 and V5 for front-end to process successfully + * @param challenges - challenges to normalize + */ +export function normalizeChallenges(challenges) { + if (challenges) { + _.map(challenges, (ch) => { + const { challenge } = ch; + if (challenge.technologies && challenge.technologies.includes('Data Science')) { + challenge.track = 'DATA_SCIENCE'; + } + return _.defaults(ch, { challenge }); + }); + } + return challenges; +} /** * Service class. */ @@ -31,7 +48,7 @@ class ReviewOpportunitiesService { .then(res => (res.ok ? res.json() : Promise.reject(new Error(`Error Code: ${res.status}`)))) .then(res => ( res.result.status === 200 - ? res.result.content + ? normalizeChallenges(res.result.content) : Promise.reject(res.result.content) )); } From 6ffac21ea1b6edda6a5f61b2ba021ca226700a19 Mon Sep 17 00:00:00 2001 From: sr_jr Date: Wed, 27 May 2020 11:57:30 +0530 Subject: [PATCH 2/2] fix tests --- __tests__/__snapshots__/index.js.snap | 1 + 1 file changed, 1 insertion(+) diff --git a/__tests__/__snapshots__/index.js.snap b/__tests__/__snapshots__/index.js.snap index e4330bd4..7bc989b4 100644 --- a/__tests__/__snapshots__/index.js.snap +++ b/__tests__/__snapshots__/index.js.snap @@ -339,6 +339,7 @@ Object { "reviewOpportunities": Object { "default": undefined, "getReviewOpportunitiesService": [Function], + "normalizeChallenges": [Function], }, "submissions": Object { "default": undefined,