Feat: Welcome Page (#17150)
This commit is contained in:
committed by
mrugesh mohapatra
parent
47bb4ca5e3
commit
156ea1af76
@@ -2,7 +2,6 @@ import _ from 'lodash';
|
||||
import { Observable } from 'rx';
|
||||
|
||||
import { unDasherize, nameify } from '../utils';
|
||||
import supportedLanguages from '../../common/utils/supported-languages';
|
||||
import {
|
||||
addNameIdMap as _addNameIdToMap,
|
||||
checkMapData,
|
||||
@@ -118,42 +117,6 @@ export function _cachedMap({ Block, Challenge }) {
|
||||
|
||||
export const cachedMap = _.once(_cachedMap);
|
||||
|
||||
export function mapChallengeToLang(
|
||||
{ translations = {}, ...challenge },
|
||||
lang
|
||||
) {
|
||||
if (!supportedLanguages[lang]) {
|
||||
lang = 'en';
|
||||
}
|
||||
const translation = translations[lang] || {};
|
||||
const isTranslated = Object.keys(translation).length > 0;
|
||||
if (lang !== 'en') {
|
||||
challenge = {
|
||||
...challenge,
|
||||
...translation,
|
||||
isTranslated
|
||||
};
|
||||
}
|
||||
return {
|
||||
...challenge,
|
||||
isTranslated
|
||||
};
|
||||
}
|
||||
|
||||
export function getMapForLang(lang) {
|
||||
return ({ entities: { challenge: challengeMap, ...entities }, result }) => {
|
||||
entities.challenge = Object.keys(challengeMap)
|
||||
.reduce((translatedChallengeMap, key) => {
|
||||
translatedChallengeMap[key] = mapChallengeToLang(
|
||||
challengeMap[key],
|
||||
lang
|
||||
);
|
||||
return translatedChallengeMap;
|
||||
}, {});
|
||||
return { result, entities };
|
||||
};
|
||||
}
|
||||
|
||||
// type ObjectId: String;
|
||||
// getChallengeById(
|
||||
// map: Observable[map],
|
||||
@@ -208,9 +171,7 @@ function loadComingSoonOrBetaChallenge({
|
||||
export function getChallenge(
|
||||
challengeDashedName,
|
||||
blockDashedName,
|
||||
map,
|
||||
lang
|
||||
) {
|
||||
map) {
|
||||
return map
|
||||
.flatMap(({ entities, result: { superBlocks } }) => {
|
||||
const superBlock = entities.superBlock;
|
||||
@@ -233,7 +194,7 @@ export function getChallenge(
|
||||
entities: {
|
||||
superBlock,
|
||||
challenge: {
|
||||
[challenge.dashedName]: mapChallengeToLang(challenge, lang)
|
||||
[challenge.dashedName]: challenge
|
||||
}
|
||||
},
|
||||
result: {
|
||||
|
||||
Reference in New Issue
Block a user