Skip to content

TCA-658 - use module.status to show a module as completed -> dev #412

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 2 commits into from
Nov 14, 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 @@ -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',
}