Skip to content

Add course completion redirect to /completed page #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
UpdateMyCertificateProgressActions,
updateMyCertificationsProgressAsync
} from '../../learn-lib'
import { authenticateAndStartCourseRoute, getFccLessonPath, LEARN_PATHS } from '../../learn.routes'
import { authenticateAndStartCourseRoute, getCertificatePath, getFccLessonPath, LEARN_PATHS } from '../../learn.routes'

import styles from './CourseCurriculum.module.scss'
import { CurriculumSummary } from './curriculum-summary'
Expand Down Expand Up @@ -124,6 +124,11 @@ const CourseCurriculum: FC<CourseCurriculumProps> = (props: CourseCurriculumProp
props.progress?.id,
])

const handleNavigateToCertificate: () => void = () => {
const certificatePath: string = getCertificatePath(props.course.provider, props.course.certification)
navigate(certificatePath)
}

/**
* If the url has a "start-course" search param,
* proceed as if the user just clicked "Start course" button
Expand Down Expand Up @@ -154,6 +159,7 @@ const CourseCurriculum: FC<CourseCurriculumProps> = (props: CourseCurriculumProp
completedPercentage={completedPercentage}
completed={isCompleted}
completedDate={props.progress?.completedDate}
onClickCertificateBtn={handleNavigateToCertificate}
isLoggedIn={isLoggedIn}
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const CurriculumSummary: FC<CurriculumSummaryProps> = (props: CurriculumSummaryP
<Button
buttonStyle='secondary'
size='xs'
label='Get your certificate'
label='View certificate'
onClick={props.onClickCertificateBtn}
/>
</>
Expand Down
21 changes: 18 additions & 3 deletions src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
useLessonProvider,
useMyCertificationProgress,
} from '../learn-lib'
import { getCoursePath, getFccLessonPath } from '../learn.routes'
import { getCertificationCompletedPath, getCoursePath, getFccLessonPath } from '../learn.routes'

import { FccFrame } from './fcc-frame'
import styles from './FreeCodeCamp.module.scss'
Expand Down Expand Up @@ -185,9 +185,24 @@ const FreeCodeCamp: FC<{}> = () => {
certificateProgress.id,
UpdateMyCertificateProgressActions.completeCertificate,
{}
).then(setCertificateProgress)
)
.then(setCertificateProgress)
.then(() => {
const completedPath: string = getCertificationCompletedPath(
providerParam,
certificationParam
)

navigate(completedPath)
})
}
}, [certificateProgress, setCertificateProgress])
}, [
certificateProgress,
certificationParam,
navigate,
providerParam,
setCertificateProgress,
])

useEffect(() => {
const certificationPath: string = routeParams.certification ?? ''
Expand Down
4 changes: 4 additions & 0 deletions src-ts/tools/learn/learn.routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export function getCertificatePath(provider: string, certification: string): str
return `/learn/${provider}/${certification}/certificate`
}

export function getCertificationCompletedPath(provider: string, certification: string): string {
return `/learn/${provider}/${certification}/completed`
}

export function getFccLessonPath(
provider: string,
certification: string,
Expand Down