Skip to content

Commit e21943d

Browse files
committed
TCA-667 - use a lesson's id to show it as completed
1 parent 38aef57 commit e21943d

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src-ts/tools/learn/learn-lib/course-outline/collapsible-item/CollapsibleItem.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import styles from './CollapsibleItem.module.scss'
1616

1717
interface CollapsibleListItem {
1818
dashedName: string
19+
id: string
1920
title: string
2021
}
2122

@@ -49,22 +50,22 @@ const CollapsibleItem: FC<CollapsibleItemProps> = (props: CollapsibleItemProps)
4950
return !!progress && !!progress.completedLessons.length
5051
}, [progress])
5152

52-
const isItemCompleted: (key: string) => boolean = (key: string) => (
53+
const isItemCompleted: (itemId: string) => boolean = (itemId: string) => (
5354
progress?.moduleStatus === LearnModuleStatus.completed ||
54-
!!progress?.completedLessons.find(l => l.dashedName === key)
55+
!!progress?.completedLessons.find(l => l.id === itemId)
5556
)
5657

57-
const stepLabel: (item: any, isActive: boolean, stepCount: string, label?: string) => ReactNode =
58+
const stepLabel: (item: CollapsibleListItem, isActive: boolean, stepCount: string, label?: string) => ReactNode =
5859
(item: any, isActive: boolean, stepCount: string, label?: string) => (
5960
<StepIcon
6061
index={stepCount}
61-
completed={isItemCompleted(item.dashedName)}
62+
completed={isItemCompleted(item.id)}
6263
active={isActive}
6364
label={label}
6465
/>
6566
)
6667

67-
const renderListItem: (item: any) => ReactNode = (item: any) => {
68+
const renderListItem: (item: CollapsibleListItem) => ReactNode = (item: any) => {
6869
const isActive: boolean = props.itemId?.(item) === props.active
6970
const stepCount: string = item.dashedName.match(/^step-(\d+)$/i)?.[1]
7071
const label: ReactNode = stepLabel(item, isActive, stepCount, !stepCount && item.title)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export interface LearnLesson {
22
dashedName: string
33
title: string
4+
id: string
45
}

src-ts/tools/learn/learn-lib/data-providers/user-certifications-provider/user-certifications-functions/learn-module-progress.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export interface LearnModuleProgress {
22
completedLessons: Array<{
33
completedDate?: string
44
dashedName: string
5+
id: string
56
}>
67
completedPercentage: number
78
module: string

0 commit comments

Comments
 (0)