diff --git a/src-ts/lib/functions/survey-functions/survey.functions.tsx b/src-ts/lib/functions/survey-functions/survey.functions.ts similarity index 100% rename from src-ts/lib/functions/survey-functions/survey.functions.tsx rename to src-ts/lib/functions/survey-functions/survey.functions.ts diff --git a/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx b/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx index 33829d44c..fb7764d0e 100644 --- a/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx +++ b/src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx @@ -271,9 +271,26 @@ const FreeCodeCamp: FC<{}> = () => { return } - // this is the last lesson to be completed in the first module completed, - // so it's good to show the trigger - surveyTriggerForUser('TCA First Module Completed', profile?.userId) + // This is the last lesson to be completed in the first module completed, + // so it's time to trigger the survey + const surveyTrigger: string = 'TCA First Module Completed' + + // If there is only one assessment in a cert (e.g. Data Analysis w/Python), + // the cert is also completed, which redirects the user to the cert page. + // So the survey needs to be delayed so that it appears on the completed + // cert page instead of the current lesson. + + // NOTE: we can't use the cert's status here bc it doesn't get set to + // completed until the UI notices the cert is complete and initiates + // the completion. And we have to use >= instead of === because it's + // possible TCA data isn't in sync w/the latest FCC curriculum. + if (progress.certificationProgressPercentage >= 100) { + setTimeout(async () => { + surveyTriggerForUser(surveyTrigger, profile?.userId) + }, 1000) + } else { + surveyTriggerForUser(surveyTrigger, profile?.userId) + } } /**