Skip to content

TCA-667 - use a lesson's id to show it as completed -> dev #416

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 4 commits into from
Nov 15, 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 @@ -16,6 +16,7 @@ import styles from './CollapsibleItem.module.scss'

interface CollapsibleListItem {
dashedName: string
id: string
title: string
}

Expand Down Expand Up @@ -50,9 +51,9 @@ const CollapsibleItem: FC<CollapsibleItemProps> = (props: CollapsibleItemProps)

const isPartial: boolean = useMemo(() => !!progress && !!progress.completedLessons.length, [progress])

const isItemCompleted: (key: string) => boolean = (key: string) => (
const isItemCompleted: (itemId: string) => boolean = (itemId: string) => (
progress?.moduleStatus === LearnModuleStatus.completed
|| !!progress?.completedLessons.find(l => l.dashedName === key)
|| !!progress?.completedLessons.find(l => l.id === itemId)
)

const stepLabel: (
Expand All @@ -64,7 +65,7 @@ const CollapsibleItem: FC<CollapsibleItemProps> = (props: CollapsibleItemProps)
= (item: CollapsibleListItem, isActive: boolean, stepCount?: string, label?: string) => (
<StepIcon
index={stepCount}
completed={isItemCompleted(item.dashedName)}
completed={isItemCompleted(item.id)}
active={isActive}
label={label}
/>
Expand All @@ -74,7 +75,7 @@ const CollapsibleItem: FC<CollapsibleItemProps> = (props: CollapsibleItemProps)
= (item: CollapsibleListItem) => {
const isActive: boolean = props.itemId?.(item) === props.active
const stepCount: string | undefined = item.dashedName.match(/^step-(\d+)$/i)?.[1]
const label: ReactNode = stepLabel(item, isActive, stepCount, !stepCount && item.title)
const label: ReactNode = stepLabel(item, isActive, stepCount, !stepCount ? item.title : undefined)
const key: string = props.itemId?.(item) ?? item.title

return (
Expand Down Expand Up @@ -127,7 +128,10 @@ const CollapsibleItem: FC<CollapsibleItemProps> = (props: CollapsibleItemProps)
)}
</div>
<div className={styles['short-desc']}>
<span className='body-small' dangerouslySetInnerHTML={{ __html: props.shortDescription.join('<br/>') }} />
<span
className='body-small'
dangerouslySetInnerHTML={{ __html: props.shortDescription.join('<br/>') }}
/>
</div>

<ul className={classNames(styles.list, 'steps-list')}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface LearnLesson {
dashedName: string
id: string
title: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface LearnModuleProgress {
completedLessons: Array<{
completedDate?: string
dashedName: string
id: string
}>
completedPercentage: number
module: string
Expand Down