Skip to content

Commit 517b9f0

Browse files
fix(client): handle builds without all challenges (freeCodeCamp#61040)
Co-authored-by: Shaun Hamilton <[email protected]>
1 parent 568840b commit 517b9f0

File tree

5 files changed

+90
-27
lines changed

5 files changed

+90
-27
lines changed

client/gatsby-node.js

Lines changed: 83 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,22 +295,56 @@ exports.createSchemaCustomization = ({ actions }) => {
295295
challenge: Challenge
296296
}
297297
type Challenge {
298-
blockType: String
298+
assignments: [String]
299+
bilibiliIds: BilibiliIds
300+
block: String
301+
blockId: String
299302
blockLayout: String
303+
blockType: String
304+
certification: String
300305
challengeFiles: [FileContents]
306+
challengeOrder: Int
307+
challengeType: Int
301308
chapter: String
309+
dashedName: String
310+
demoType: String
311+
description: String
312+
disableLoopProtectPreview: Boolean
313+
disableLoopProtectTests: Boolean
302314
explanation: String
315+
fillInTheBlank: FillInTheBlank
316+
forumTopicId: Int
317+
hasEditableBoundaries: Boolean
318+
helpCategory: String
303319
hooks: Hooks
304-
notes: String
305-
url: String
306-
assignments: [String]
307-
prerequisites: [PrerequisiteChallenge]
320+
id: String
321+
instructions: String
322+
isComingSoon: Boolean
323+
isLastChallengeInBlock: Boolean
324+
isPrivate: Boolean
308325
module: String
309326
msTrophyId: String
310-
fillInTheBlank: FillInTheBlank
327+
notes: String
328+
order: Int
329+
prerequisites: [PrerequisiteChallenge]
330+
questions: [Question]
331+
quizzes: [Quiz]
332+
required: [RequiredResource]
311333
scene: Scene
334+
solutions: [[FileContents]]
335+
suborder: Int
336+
superBlock: String
337+
superOrder: Int
338+
template: String
339+
tests: [Test]
340+
title: String
312341
transcript: String
313-
quizzes: [Quiz]
342+
translationPending: Boolean
343+
url: String
344+
usesMultifileEditor: Boolean
345+
videoId: String
346+
videoLocaleIds: VideoLocaleIds
347+
videoUrl: String
314348
}
315349
type FileContents {
316350
fileKey: String
@@ -320,11 +354,53 @@ exports.createSchemaCustomization = ({ actions }) => {
320354
head: String
321355
tail: String
322356
editableRegionBoundaries: [Int]
357+
path: String
358+
error: String
359+
seed: String
360+
id: String
361+
history: [String]
323362
}
324363
type PrerequisiteChallenge {
325364
id: String
326365
title: String
327366
}
367+
type VideoLocaleIds {
368+
espanol: String
369+
italian: String
370+
portuguese: String
371+
}
372+
type BilibiliIds {
373+
aid: Int
374+
bvid: String
375+
cid: Int
376+
}
377+
type Question {
378+
text: String
379+
answers: [Answer]
380+
solution: Int
381+
}
382+
type Answer {
383+
answer: String
384+
feedback: String
385+
}
386+
type RequiredResource {
387+
link: String
388+
raw: Boolean
389+
src: String
390+
crossDomain: Boolean
391+
}
392+
type Hooks {
393+
beforeAll: String
394+
beforeEach: String
395+
afterAll: String
396+
afterEach: String
397+
}
398+
type Test {
399+
id: String
400+
text: String
401+
testString: String
402+
title: String
403+
}
328404
type FillInTheBlank {
329405
sentence: String
330406
blanks: [Blank]

client/src/pages/learn.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ interface LearnPageProps {
5757
challenge: {
5858
fields: Slug;
5959
};
60-
};
60+
} | null;
6161
};
6262
}
6363

@@ -67,18 +67,14 @@ function LearnPage({
6767
isSignedIn,
6868
fetchState: { pending, complete },
6969
user,
70-
data: {
71-
challengeNode: {
72-
challenge: {
73-
fields: { slug }
74-
}
75-
}
76-
}
70+
data: { challengeNode }
7771
}: LearnPageProps) {
7872
const { name, completedChallengeCount, isDonating } = user ?? EMPTY_USER;
7973

8074
const { t } = useTranslation();
8175

76+
const slug = challengeNode?.challenge?.fields?.slug || '';
77+
8278
const onLearnDonationAlertClick = () => {
8379
callGA({
8480
event: 'donation_related',

client/src/redux/prop-types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ export type ChallengeNode = {
188188
fields: Fields;
189189
fillInTheBlank: FillInTheBlank;
190190
forumTopicId: number;
191-
guideUrl: string;
192191
head: string[];
193192
hasEditableBoundaries: boolean;
194193
helpCategory: string;

client/src/templates/Introduction/components/super-block-intro.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface SuperBlockIntroQueryData {
2020
slug: string;
2121
};
2222
};
23-
};
23+
} | null;
2424
}
2525

2626
type ReduxProps = ConnectedProps<typeof connector>;
@@ -115,13 +115,7 @@ function SuperBlockIntro({
115115
note: string;
116116
};
117117

118-
const {
119-
challengeNode: {
120-
challenge: {
121-
fields: { slug: firstChallengeSlug }
122-
}
123-
}
124-
} = useStaticQuery<SuperBlockIntroQueryData>(graphql`
118+
const { challengeNode } = useStaticQuery<SuperBlockIntroQueryData>(graphql`
125119
query SuperBlockIntroQuery {
126120
challengeNode(
127121
challenge: {
@@ -139,6 +133,7 @@ function SuperBlockIntro({
139133
}
140134
`);
141135

136+
const firstChallengeSlug = challengeNode?.challenge?.fields?.slug || '';
142137
const {
143138
title: i18nSuperBlock,
144139
intro: superBlockIntroText,

curriculum/schema/challenge-schema.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ const schema = Joi.object().keys({
162162
}),
163163
certification: Joi.string().regex(slugWithSlashRE),
164164
challengeType: Joi.number().min(0).max(31).required(),
165-
checksum: Joi.number(),
166165
// TODO: require this only for normal challenges, not certs
167166
dashedName: Joi.string().regex(slugRE),
168167
demoType: Joi.string().valid('onClick', 'onLoad'),
@@ -183,7 +182,6 @@ const schema = Joi.object().keys({
183182
then: Joi.string()
184183
}),
185184
challengeFiles: Joi.array().items(fileJoi),
186-
guideUrl: Joi.string().uri({ scheme: 'https' }),
187185
hasEditableBoundaries: Joi.boolean(),
188186
helpCategory: Joi.valid(
189187
'JavaScript',
@@ -217,7 +215,6 @@ const schema = Joi.object().keys({
217215
otherwise: Joi.string().allow('')
218216
}),
219217
isComingSoon: Joi.bool(),
220-
isLocked: Joi.bool(),
221218
module: Joi.string().when('superBlock', {
222219
is: chapterBasedSuperBlocks,
223220
then: Joi.required(),

0 commit comments

Comments
 (0)