mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
refactor: blockType -> blockLabel (#62548)
Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
808d0d0d74
commit
27a54624c3
@@ -4,6 +4,7 @@ import { omit } from 'lodash';
|
||||
import { submitTypes } from '../../../shared-dist/config/challenge-types';
|
||||
import { type ChallengeNode } from '../../../client/src/redux/prop-types';
|
||||
import { SuperBlocks } from '../../../shared-dist/config/curriculum';
|
||||
import { patchBlock } from './patches';
|
||||
|
||||
export type CurriculumIntros = {
|
||||
[keyValue in SuperBlocks]: {
|
||||
@@ -121,10 +122,13 @@ export function buildExtCurriculumDataV1(
|
||||
|
||||
superBlock[superBlockKey]['blocks'][blockName]['desc'] = block['intro'];
|
||||
|
||||
superBlock[superBlockKey]['blocks'][blockName]['challenges'] = omit(
|
||||
curriculum[superBlockKey]['blocks'][blockName]['meta'],
|
||||
['chapter', 'module']
|
||||
);
|
||||
superBlock[superBlockKey]['blocks'][blockName]['challenges'] =
|
||||
patchBlock(
|
||||
omit(curriculum[superBlockKey]['blocks'][blockName]['meta'], [
|
||||
'chapter',
|
||||
'module'
|
||||
])
|
||||
);
|
||||
|
||||
const blockChallenges =
|
||||
curriculum[superBlockKey]['blocks'][blockName]['challenges'];
|
||||
|
||||
@@ -6,6 +6,7 @@ import { type ChallengeNode } from '../../../client/src/redux/prop-types';
|
||||
import { SuperBlocks } from '../../../shared-dist/config/curriculum';
|
||||
import type { Chapter } from '../../../shared-dist/config/chapters';
|
||||
import { getSuperblockStructure } from '../../../curriculum/src/file-handler';
|
||||
import { patchBlock } from './patches';
|
||||
|
||||
export type CurriculumIntros =
|
||||
| BlockBasedCurriculumIntros
|
||||
@@ -316,7 +317,9 @@ export function buildExtCurriculumDataV2(
|
||||
const blockData = blocksWithData[block];
|
||||
return {
|
||||
intro: superBlockIntros.blocks[block].intro,
|
||||
meta: omit(blockData.meta, ['chapter', 'module'])
|
||||
meta: patchBlock(
|
||||
omit(blockData.meta, ['chapter', 'module'])
|
||||
)
|
||||
};
|
||||
})
|
||||
}))
|
||||
@@ -339,7 +342,7 @@ export function buildExtCurriculumDataV2(
|
||||
|
||||
return {
|
||||
intro: intros[superBlockKey].blocks[blockName].intro,
|
||||
meta: blockData.meta
|
||||
meta: patchBlock(blockData.meta)
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
export const patchBlock = (meta: Record<string, unknown>) => {
|
||||
const { blockLabel, ...rest } = meta;
|
||||
return {
|
||||
...rest,
|
||||
blockType: blockLabel
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user