Skip to content

Commit 970815c

Browse files
committed
Move name of survey in learn-config, move storage hook in learn-lib
1 parent caf8e3b commit 970815c

File tree

7 files changed

+25
-6
lines changed

7 files changed

+25
-6
lines changed

src-ts/tools/learn/course-completed/CourseCompletedPage.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
ProfileContextData,
1212
surveyTriggerForUser,
1313
textFormatGetSafeString,
14-
useLocalStorage,
1514
} from '../../../lib'
1615
import {
1716
AllCertificationsProviderData,
@@ -23,11 +22,13 @@ import {
2322
useLearnBreadcrumb,
2423
UserCertificationProgressProviderData,
2524
UserCertificationProgressStatus,
25+
useShowSurvey,
2626
} from '../learn-lib'
2727
import { getCertificatePath, getCoursePath, LEARN_PATHS, rootRoute } from '../learn.routes'
2828

2929
import { ReactComponent as StarsSvg } from './stars.svg'
3030
import styles from './CourseCompletedPage.module.scss'
31+
import { LearnConfig } from '../learn-config'
3132

3233
const CourseCompletedPage: FC<{}> = () => {
3334

@@ -41,7 +42,7 @@ const CourseCompletedPage: FC<{}> = () => {
4142
const [showSurvey, setShowSurvey]: [
4243
string,
4344
Dispatch<SetStateAction<string>>
44-
] = useLocalStorage<string>('tca-show-survey', '')
45+
] = useShowSurvey()
4546

4647
const {
4748
course: courseData,
@@ -96,7 +97,7 @@ const CourseCompletedPage: FC<{}> = () => {
9697

9798
useEffect(() => {
9899
if (ready && showSurvey === certificationParam) {
99-
surveyTriggerForUser('TCA First Module Completed', profile?.userId)
100+
surveyTriggerForUser(LearnConfig.SURVEY.COMPLETED_FIRST_MODULE, profile?.userId)
100101
setShowSurvey('')
101102
}
102103
}, [ready, showSurvey, certificationParam]);

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
ProfileContextData,
2121
surveyTriggerForUser,
2222
textFormatGetSafeString,
23-
useLocalStorage,
2423
} from '../../../lib'
2524
import {
2625
CoursesProviderData,
@@ -40,13 +39,15 @@ import {
4039
UserCertificationProgressStatus,
4140
userCertificationProgressUpdateAsync,
4241
UserCertificationUpdateProgressActions,
42+
useShowSurvey,
4343
} from '../learn-lib'
4444
import { getCertificationCompletedPath, getCoursePath, getLessonPathFromModule } from '../learn.routes'
4545

4646
import { FccFrame } from './fcc-frame'
4747
import { FccSidebar } from './fcc-sidebar'
4848
import { TitleNav } from './title-nav'
4949
import styles from './FreeCodeCamp.module.scss'
50+
import { LearnConfig } from '../learn-config'
5051

5152
const FreeCodeCamp: FC<{}> = () => {
5253

@@ -70,7 +71,7 @@ const FreeCodeCamp: FC<{}> = () => {
7071
const [showSurvey, setShowSurvey]: [
7172
string,
7273
Dispatch<SetStateAction<string>>
73-
] = useLocalStorage<string>('tca-show-survey', '')
74+
] = useShowSurvey()
7475

7576
const {
7677
certificationProgress: certificateProgress,
@@ -455,7 +456,7 @@ const FreeCodeCamp: FC<{}> = () => {
455456

456457
useEffect(() => {
457458
if (ready && showSurvey === certificationParam) {
458-
surveyTriggerForUser('TCA First Module Completed', profile?.userId)
459+
surveyTriggerForUser(LearnConfig.SURVEY.COMPLETED_FIRST_MODULE, profile?.userId)
459460
setShowSurvey('')
460461
}
461462
}, [

src-ts/tools/learn/learn-config/learn-config.model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ export interface LearnConfigModel {
77
value: string,
88
}
99
CLIENT: string
10+
SURVEY: {
11+
COMPLETED_FIRST_MODULE: string
12+
}
1013
}

src-ts/tools/learn/learn-config/learn.default.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ export const LearnConfigDefault: LearnConfigModel = {
1111
value: 'certificate-container',
1212
},
1313
CLIENT: 'https://fcc.topcoder-dev.com:4431',
14+
SURVEY: {
15+
COMPLETED_FIRST_MODULE: 'TCA First Module Completed',
16+
}
1417
}

src-ts/tools/learn/learn-lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ export * from './data-providers'
77
export * from './learn-breadcrumb-provider'
88
export * from './learn-swr'
99
export * from './my-course-card'
10+
export * from './survey'
1011
export * from './svgs'
1112
export * from './wave-hero'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './use-show-survey'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Dispatch, SetStateAction } from "react"
2+
import { useLocalStorage } from "../../../../lib"
3+
4+
export const useShowSurvey = (): [
5+
string,
6+
Dispatch<SetStateAction<string>>
7+
] => {
8+
return useLocalStorage<string>('tca-show-survey', '');
9+
}

0 commit comments

Comments
 (0)