Feat: Welcome Page (#17150)

This commit is contained in:
Stuart Taylor
2018-05-15 06:12:05 +01:00
committed by mrugesh mohapatra
parent 47bb4ca5e3
commit 156ea1af76
172 changed files with 693 additions and 9738 deletions

View File

@@ -1,52 +1,7 @@
import flowRight from 'lodash/flowRight';
import { createNameIdMap } from '../../utils/map.js';
import { partial } from 'lodash';
export function filterComingSoonBetaChallenge(
isDev = false,
{ isComingSoon, isBeta }
) {
return !(isComingSoon || isBeta) ||
isDev;
}
export function filterComingSoonBetaFromEntities(
{ challenge: challengeMap, block: blockMap = {}, ...rest },
isDev = false
) {
const filter = partial(filterComingSoonBetaChallenge, isDev);
return {
...rest,
block: Object.keys(blockMap)
.map(dashedName => {
const block = blockMap[dashedName];
const filteredChallenges = block.challenges
.map(dashedName => challengeMap[dashedName])
.filter(filter)
.map(challenge => challenge.dashedName);
return {
...block,
challenges: [ ...filteredChallenges ]
};
})
.reduce((blockMap, block) => {
blockMap[block.dashedName] = block;
return blockMap;
}, {}),
challenge: Object.keys(challengeMap)
.map(dashedName => challengeMap[dashedName])
.filter(filter)
.reduce((challengeMap, challenge) => {
challengeMap[challenge.dashedName] = challenge;
return challengeMap;
}, {})
};
}
export const shapeChallenges = flowRight(
filterComingSoonBetaFromEntities,
entities => ({
...entities,
...createNameIdMap(entities)