feat(UI): take back to learn map after finishing a block (#50011)

Co-authored-by: moT01 <20648924+moT01@users.noreply.github.com>
This commit is contained in:
DEVelooper29
2023-06-23 02:49:01 +05:30
committed by GitHub
parent 9859c8479a
commit f9e0303c32
4 changed files with 88 additions and 9 deletions
@@ -75,6 +75,31 @@ function getTemplateComponent(challengeType) {
return views[viewTypes[challengeType]];
}
function getNextChallengeMeta(_node, index, nodeArray) {
const next = nodeArray[index + 1];
if (next) {
const { superBlock, block } = next.node.challenge;
return {
superBlock,
block,
blockHashSlug: createBlockHashSlug(_node)
};
}
return null;
}
function createBlockHashSlug(_node) {
if (_node) {
const {
block,
fields: { slug }
} = _node;
const re = new RegExp(`${block}.*`);
return slug.replace(re, `#${block}`);
}
return null;
}
exports.createChallengePages = function (createPage) {
return function ({ node: { challenge } }, index, allChallengeEdges) {
const {
@@ -96,6 +121,7 @@ exports.createChallengePages = function (createPage) {
component: getTemplateComponent(challengeType),
context: {
challengeMeta: {
blockHashSlug: createBlockHashSlug(challenge),
dashedName,
certification,
superBlock,
@@ -103,6 +129,11 @@ exports.createChallengePages = function (createPage) {
isFirstStep: getIsFirstStep(challenge, index, allChallengeEdges),
template,
required,
nextChallengeMeta: getNextChallengeMeta(
challenge,
index,
allChallengeEdges
),
nextChallengePath: getNextChallengePath(
challenge,
index,