Skip to content

Commit 97e142f

Browse files
committed
Code review fixes
1 parent bc73636 commit 97e142f

File tree

2 files changed

+17
-22
lines changed
  • src-ts/tools/learn
    • free-code-camp
    • learn-lib/data-providers/user-certifications-provider/user-certifications-functions

2 files changed

+17
-22
lines changed

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

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
UserRole,
2626
} from '../../../lib'
2727
import {
28-
adminCertificationProgressCompleteCourseAsync,
2928
CoursesProviderData,
3029
LearnLesson,
3130
LearnModule,
@@ -37,6 +36,7 @@ import {
3736
useGetLesson,
3837
useGetUserCertificationProgress,
3938
useLearnBreadcrumb,
39+
userCertificationProgressAutocompleteCourse,
4040
userCertificationProgressCompleteCourseAsync,
4141
UserCertificationProgressProviderData,
4242
userCertificationProgressStartAsync,
@@ -452,22 +452,21 @@ const FreeCodeCamp: FC<{}> = () => {
452452
* Complete course shortcut for admins
453453
*/
454454
function adminCompleteCourse(): void {
455-
const confirmed = confirm('Hey, You about to complete the certification. Are you sure?');
456-
if (certificateProgress && confirmed) {
457-
adminCertificationProgressCompleteCourseAsync(certificateProgress.id)
458-
.then(setCertificateProgress)
459-
.then(() => {
460-
toast.info(
461-
<>
462-
<p>Yay, success! You completed the course.</p>
463-
</>
464-
)
465-
})
466-
.catch(error => {
467-
logError(error)
468-
toast.error('Oops! We couldn\'t complete your request as some error happened. See console for more...')
469-
})
455+
const confirmed = confirm('Hey, you\'re about to auto-complete this entire course. Are you sure?');
456+
457+
if (!certificateProgress?.id || !confirmed) {
458+
return
470459
}
460+
461+
userCertificationProgressAutocompleteCourse(certificateProgress.id)
462+
.then(setCertificateProgress)
463+
.then(() => {
464+
toast.info(<p>Yay, success! You completed the course.</p>)
465+
})
466+
.catch(error => {
467+
logError(error)
468+
toast.error('Oops! We couldn\'t complete your request as some error happened. See console for more...')
469+
})
471470
}
472471

473472
return (
@@ -476,11 +475,7 @@ const FreeCodeCamp: FC<{}> = () => {
476475
<div className={styles.wrapBreadcrumb}>
477476
<Breadcrumb items={breadcrumb} />
478477
{
479-
lesson
480-
&& profile
481-
&& profile.roles
482-
&& profile.roles.includes(UserRole.tcaAdmin)
483-
&& (
478+
lesson && profile?.roles?.includes(UserRole.tcaAdmin) && (
484479
<Button
485480
buttonStyle={'secondary'}
486481
className={styles.completeCourseBtn}

src-ts/tools/learn/learn-lib/data-providers/user-certifications-provider/user-certifications-functions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export * from './learn-module-status.enum'
44
export * from './user-certification-progress-status.enum'
55
export * from './user-certification-update-progress-actions.enum'
66
export {
7-
adminCompleteCourse as adminCertificationProgressCompleteCourseAsync,
7+
adminCompleteCourse as userCertificationProgressAutocompleteCourse,
88
completeCourse as userCertificationProgressCompleteCourseAsync,
99
startAsync as userCertificationProgressStartAsync,
1010
updateAsync as userCertificationProgressUpdateAsync,

0 commit comments

Comments
 (0)