Skip to content

Commit df67f69

Browse files
TCA-790 Delay all calls to the survey so they don't close when the user goes to the next lesson. #time 30m
1 parent 83f8a8d commit df67f69

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

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

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { debounce } from 'lodash'
12
import {
23
Dispatch,
34
FC,
@@ -45,7 +46,6 @@ import { FccFrame } from './fcc-frame'
4546
import { FccSidebar } from './fcc-sidebar'
4647
import { TitleNav } from './title-nav'
4748
import styles from './FreeCodeCamp.module.scss'
48-
import { debounce } from 'lodash'
4949

5050
const FreeCodeCamp: FC<{}> = () => {
5151

@@ -212,6 +212,7 @@ const FreeCodeCamp: FC<{}> = () => {
212212
profile?.userId,
213213
])
214214

215+
// eslint-disable-next-line react-hooks/exhaustive-deps
215216
const handleFccLessonComplete: (challengeUuid: string) => void = useCallback(debounce((challengeUuid: string) => {
216217

217218
const currentLesson: { [key: string]: string } = {
@@ -274,30 +275,18 @@ const FreeCodeCamp: FC<{}> = () => {
274275

275276
// This is the last lesson to be completed in the first module completed,
276277
// so it's time to trigger the survey
277-
const surveyTrigger: string = 'TCA First Module Completed'
278-
279-
// If there is only one assessment in a cert (e.g. Data Analysis w/Python),
280-
// the cert is also completed, which redirects the user to the cert page.
281-
// So the survey needs to be delayed so that it appears on the completed
282-
// cert page instead of the current lesson.
283-
284-
// NOTE: we can't use the cert's status here bc it doesn't get set to
285-
// completed until the UI notices the cert is complete and initiates
286-
// the completion. And we have to use >= instead of === because it's
287-
// possible TCA data isn't in sync w/the latest FCC curriculum.
288-
if (progress.certificationProgressPercentage >= 100) {
289-
setTimeout(async () => {
290-
surveyTriggerForUser(surveyTrigger, profile?.userId)
291-
}, 1000)
292-
} else {
293-
surveyTriggerForUser(surveyTrigger, profile?.userId)
294-
}
278+
// NOTE: We have to add a delay, otherwise the survey closes when the user
279+
// is automatically redirected to the next lesson.
280+
setTimeout(async () => {
281+
surveyTriggerForUser('TCA First Module Completed', profile?.userId)
282+
}, 1000)
295283
}
296284

297285
/**
298286
* Handle the navigation away from the last step of the course in the FCC frame
299287
* @returns
300288
*/
289+
// eslint-disable-next-line react-hooks/exhaustive-deps
301290
const handleFccLastLessonNavigation: () => void = useCallback(debounce(() => {
302291

303292
if (!certificateProgress) {

0 commit comments

Comments
 (0)