Skip to content

Commit 5436a5a

Browse files
committed
When user starts a new course, call swr.mutate with the new certificationProgress data.
1 parent 96367c8 commit 5436a5a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src-ts/tools/learn/course-details/CourseDetailsPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const CourseDetailsPage: FC<{}> = () => {
4848
const {
4949
certificationProgress: progress,
5050
ready: progressReady,
51+
setCertificateProgress,
5152
}: UserCertificationProgressProviderData = useGetUserCertificationProgress(
5253
profile?.userId,
5354
routeParams.provider,
@@ -214,6 +215,7 @@ const CourseDetailsPage: FC<{}> = () => {
214215
progress={progress}
215216
progressReady={progressReady}
216217
profile={profile}
218+
setCertificateProgress={setCertificateProgress}
217219
/>
218220
</div>
219221
</div>

src-ts/tools/learn/course-details/course-curriculum/CourseCurriculum.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ interface CourseCurriculumProps {
3131
profile?: UserProfile
3232
progress?: LearnUserCertificationProgress
3333
progressReady?: boolean
34+
setCertificateProgress: (d: LearnUserCertificationProgress) => void
3435
}
3536

3637
const CourseCurriculum: FC<CourseCurriculumProps> = (props: CourseCurriculumProps) => {
@@ -108,7 +109,7 @@ const CourseCurriculum: FC<CourseCurriculumProps> = (props: CourseCurriculumProp
108109
}
109110

110111
if (!props.progress?.id) {
111-
await userCertificationProgressStartAsync(
112+
const progress: LearnUserCertificationProgress = await userCertificationProgressStartAsync(
112113
props.profile.userId,
113114
props.course.certificationId,
114115
props.course.id,
@@ -117,6 +118,9 @@ const CourseCurriculum: FC<CourseCurriculumProps> = (props: CourseCurriculumProp
117118
module: props.course.modules[0].meta.dashedName,
118119
},
119120
)
121+
122+
// update progress with data returned from calling the start progress endpoint
123+
props.setCertificateProgress(progress)
120124
} else {
121125
await userCertificationProgressUpdateAsync(
122126
props.progress.id,

0 commit comments

Comments
 (0)