From b81cea4b08042924747d5e9bd885b2b255b3ef16 Mon Sep 17 00:00:00 2001 From: Stuart Taylor Date: Tue, 27 Feb 2018 14:29:37 +0000 Subject: [PATCH] fix(profile): Fix challenges of undefined Error --- common/app/entities/index.js | 4 ++-- common/app/redux/fetch-challenges-epic.js | 4 +++- server/services/mapUi.js | 17 +++++++++++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/common/app/entities/index.js b/common/app/entities/index.js index 8a85e99a11..bb8aeda1c1 100644 --- a/common/app/entities/index.js +++ b/common/app/entities/index.js @@ -110,14 +110,14 @@ export function projectsSelector(state) { key.includes('projects') && !key.includes('coding-interview') ) .map(key => blocks[key]) - .map(({ name, challenges, superBlock }) => { + .map(({ title, challenges, superBlock }) => { const projectChallengeDashNames = challenges // remove any project intros .filter(chal => !chal.includes('get-set-for')); const projectChallenges = projectChallengeDashNames .map(dashedName => selectiveChallengeTitleSelector(state, dashedName)); return { - projectBlockName: name, + projectBlockName: title, superBlock, challenges: projectChallenges, challengeNameIdMap: pick( diff --git a/common/app/redux/fetch-challenges-epic.js b/common/app/redux/fetch-challenges-epic.js index b0d0383ee9..1205304d7e 100644 --- a/common/app/redux/fetch-challenges-epic.js +++ b/common/app/redux/fetch-challenges-epic.js @@ -68,7 +68,9 @@ export function fetchChallengesForBlockEpic( .flatMapLatest(({ type, payload }) => { const fetchAnotherBlock = type === types.fetchNewBlock.start; const state = getState(); - let { block: blockName } = challengeSelector(state); + let { + block: blockName = 'basic-html-and-html5' + } = challengeSelector(state); const lang = langSelector(state); if (fetchAnotherBlock) { diff --git a/server/services/mapUi.js b/server/services/mapUi.js index b7dca26595..9360deac3e 100644 --- a/server/services/mapUi.js +++ b/server/services/mapUi.js @@ -34,10 +34,19 @@ export default function mapUiService(app) { }, {}); const blockMap = Object.keys(fullBlockMap) .map(block => fullBlockMap[block]) - .reduce((map, { dashedName, title, time, challenges }) => { - map[dashedName] = { dashedName, title, time, challenges }; - return map; - }, {}); + .reduce( + (map, { dashedName, title, time, challenges, superBlock }) => { + map[dashedName] = { + dashedName, + title, + time, + challenges, + superBlock + }; + return map; + }, + {} + ); const challengeMap = Object.keys(fullChallengeMap) .map(challenge => fullChallengeMap[challenge]) .reduce((map, challenge) => {