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, 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) )); }