Skip to content
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 @@ -3,7 +3,12 @@ import { Dispatch, FC, ReactNode, SetStateAction, useCallback, useMemo, useState
import { Link } from 'react-router-dom'

import { IconOutline, IconSolid } from '../../../../../lib'
import { LearnModule, LearnModuleProgress, LearnUserCertificationProgress } from '../../../learn-lib'
import {
LearnModule,
LearnModuleProgress,
LearnModuleStatus,
LearnUserCertificationProgress
} from '../../../learn-lib'
import { StatusIcon } from '../status-icon'
import { StepIcon } from '../step-icon'

Expand Down Expand Up @@ -40,15 +45,12 @@ const CollapsibleItem: FC<CollapsibleItemProps> = (props: CollapsibleItemProps)
return props.progress?.find(m => m.module === props.moduleKey)
}, [props.progress, props.moduleKey])

const isCompleted: boolean = useMemo(() => {
return !!progress && progress.lessonCount === progress?.completedLessons.length
}, [progress])

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

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

Expand Down Expand Up @@ -86,7 +88,7 @@ const CollapsibleItem: FC<CollapsibleItemProps> = (props: CollapsibleItemProps)
return (
<div className={classNames(styles['wrap'], isOpen ? 'is-open' : 'collapsed')}>
<div className={styles['title-row']} onClick={toggle}>
<StatusIcon completed={isCompleted} partial={isPartial} />
<StatusIcon completed={progress?.moduleStatus === LearnModuleStatus.completed} partial={isPartial} />
<span className={styles['title']}>
{props.isAssessment && (
<div className={classNames(styles['title-tag'], 'label')}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './learn-user-certification-progress.model'
export * from './learn-module-progress.model'
export * from './learn-module-status.enum'
export * from './user-certification-progress-status.enum'
export * from './user-certification-update-progress-actions.enum'
export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export interface LearnModuleProgress {
dashedName: string
}>
completedPercentage: number
lessonCount: number
module: string
moduleStatus: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum LearnModuleStatus {
init = 'not-started',
inProgress = 'in-progress',
completed = 'completed',
}