Skip to content

Commit da181d4

Browse files
authored
Merge pull request #278 from topcoder-platform/TCA-367_fcc-page-params-check
TCA-367 - FCC page: check if url params are valid, if not redirect to…
2 parents 98fa2b0 + 8edfcaf commit da181d4

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,32 @@ const FreeCodeCamp: FC<{}> = () => {
285285
setCertificateProgress,
286286
])
287287

288+
useEffect(() => {
289+
if (courseDataReady && courseData) {
290+
const moduleParamData: LearnModule = courseData.modules.find(m => m.key === moduleParam) ?? courseData.modules[0]
291+
const lessonParamExists: boolean = !!moduleParamData?.lessons.find(l => l.dashedName === lessonParam)
292+
293+
if (!lessonParamExists) {
294+
const lessonPath: string = getLessonPathFromModule(
295+
providerParam,
296+
certificationParam,
297+
moduleParamData.key,
298+
moduleParamData.lessons[0].dashedName,
299+
)
300+
301+
navigate(lessonPath)
302+
}
303+
}
304+
}, [
305+
certificationParam,
306+
courseData,
307+
courseDataReady,
308+
lessonParam,
309+
moduleParam,
310+
navigate,
311+
providerParam,
312+
])
313+
288314
useEffect(() => {
289315
const certificationPath: string = routeParams.certification ?? ''
290316
const modulePath: string = routeParams.module ?? ''

src-ts/tools/learn/learn-lib/functions/learn-xhr.functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'
1+
import { AxiosInstance, AxiosRequestConfig } from 'axios'
22

33
import { xhrCreateInstance, xhrGetAsync, xhrPostAsync, xhrPutAsync } from '../../../../lib'
44

0 commit comments

Comments
 (0)