11import { FC , useContext , useMemo } from 'react'
22
3- import { Breadcrumb , BreadcrumbItemModel , ContentLayout , Portal , profileContext , ProfileContextData } from '../../../lib'
3+ import { Breadcrumb , BreadcrumbItemModel , ContentLayout , LoadingSpinner , Portal , profileContext , ProfileContextData } from '../../../lib'
44import {
55 AllCertificationsProviderData ,
66 LearnCertification ,
@@ -24,9 +24,11 @@ interface CertificatesByIdType {
2424
2525const MyLearning : FC < { } > = ( ) => {
2626
27- const { profile } : ProfileContextData = useContext ( profileContext )
28- const { completed, inProgress } : UserCertificationsProviderData = useUserCertifications ( )
29- const { certifications } : AllCertificationsProviderData = useAllCertifications ( )
27+ const { profile, initialized : profileReady } : ProfileContextData = useContext ( profileContext )
28+ const { completed, inProgress, ready : coursesReady } : UserCertificationsProviderData = useUserCertifications ( )
29+ const { certifications, ready : certificatesReady } : AllCertificationsProviderData = useAllCertifications ( )
30+
31+ const ready : boolean = profileReady && coursesReady && certificatesReady
3032
3133 const certificatesById : CertificatesByIdType = useMemo ( ( ) => (
3234 certifications . reduce ( ( certifs , certificate ) => {
@@ -46,6 +48,8 @@ const MyLearning: FC<{}> = () => {
4648 < ContentLayout contentClass = { styles [ 'content-layout' ] } >
4749 < Breadcrumb items = { breadcrumb } />
4850 < div className = { styles [ 'wrap' ] } >
51+ < LoadingSpinner hide = { ready } className = { styles [ 'loading-spinner' ] } />
52+
4953 < Portal portalId = 'page-subheader-portal-el' >
5054 < div className = { styles [ 'hero-wrap' ] } >
5155 < WaveHero
@@ -60,36 +64,40 @@ const MyLearning: FC<{}> = () => {
6064 </ div >
6165 </ Portal >
6266
63- < div className = { styles [ 'courses-area' ] } >
64- { inProgress . map ( ( certif ) => (
65- < MyCourseInProgressCard
66- certification = { certificatesById [ certif . certificationId ] }
67- key = { certif . certificationId }
68- theme = 'detailed'
69- currentLesson = { certif . currentLesson }
70- completedPercentage = { certif . courseProgressPercentage / 100 }
71- startDate = { certif . startDate }
72- />
73- ) ) }
74- </ div >
75-
76- { ! ! completed . length && (
77- < div className = { styles [ 'courses-area' ] } >
78- < div className = { styles [ 'title-line' ] } >
79- < LearningHat />
80- < h2 className = 'details' > Completed Courses</ h2 >
81- </ div >
82-
83- < div className = { styles [ 'cards-wrap' ] } >
84- { completed . map ( ( certif ) => (
85- < MyCourseCompletedCard
67+ { ready && (
68+ < >
69+ < div className = { styles [ 'courses-area' ] } >
70+ { inProgress . map ( ( certif ) => (
71+ < MyCourseInProgressCard
8672 certification = { certificatesById [ certif . certificationId ] }
8773 key = { certif . certificationId }
88- completed = { certif . completedDate }
74+ theme = 'detailed'
75+ currentLesson = { certif . currentLesson }
76+ completedPercentage = { certif . courseProgressPercentage / 100 }
77+ startDate = { certif . startDate }
8978 />
9079 ) ) }
9180 </ div >
92- </ div >
81+
82+ { ! ! completed . length && (
83+ < div className = { styles [ 'courses-area' ] } >
84+ < div className = { styles [ 'title-line' ] } >
85+ < LearningHat />
86+ < h2 className = 'details' > Completed Courses</ h2 >
87+ </ div >
88+
89+ < div className = { styles [ 'cards-wrap' ] } >
90+ { completed . map ( ( certif ) => (
91+ < MyCourseCompletedCard
92+ certification = { certificatesById [ certif . certificationId ] }
93+ key = { certif . certificationId }
94+ completed = { certif . completedDate }
95+ />
96+ ) ) }
97+ </ div >
98+ </ div >
99+ ) }
100+ </ >
93101 ) }
94102 </ div >
95103 </ ContentLayout >
0 commit comments