Skip to content

Commit 9df003a

Browse files
committed
TCA-870 add the public user cert route
1 parent b2086d4 commit 9df003a

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

src-ts/tools/learn/learn-lib/data-providers/user-completed-tca-certifications-provider/user-completed-tca-certifications.provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { UserCompletedTCACertification } from './user-completed-tca-certificatio
66
import { UserCompletedTCACertificationsProviderData } from './user-completed-tca-certifications-provider-data.model'
77

88
const COMPLETED_CERTS_MOCK = [
9-
{ status: 'comleted', trackType: 'web dev', completedDate: '' },
9+
{ status: 'comleted', trackType: 'web dev', completedDate: 'Dec 19, 2022' },
1010
]
1111

1212
export function useGetUserTCACompletedCertifications(

src-ts/tools/learn/learn.routes.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const FreeCodeCamp: LazyLoadedComponent = lazyLoad(() => import('./free-code-cam
1212
const MyLearning: LazyLoadedComponent = lazyLoad(() => import('./my-learning'), 'MyLearning')
1313
const LandingLearn: LazyLoadedComponent = lazyLoad(() => import('./Learn'))
1414
const MyTCACertificate: LazyLoadedComponent = lazyLoad(() => import('./tca-certificate'), 'MyTCACertificate')
15+
const UserTCACertificate: LazyLoadedComponent = lazyLoad(() => import('./tca-certificate'), 'UserTCACertificate')
1516

1617
export enum LEARN_PATHS {
1718
certificate = '/certificate',
@@ -147,6 +148,12 @@ export const learnRoutes: ReadonlyArray<PlatformRoute> = [
147148
id: 'My TCA Certification',
148149
route: 'tca-certifications/:certification/certificate',
149150
},
151+
{
152+
children: [],
153+
element: <UserTCACertificate />,
154+
id: 'User TCA Certification',
155+
route: 'tca-certifications/:certification/:memberHandle/certificate',
156+
},
150157
],
151158
element: <LandingLearn />,
152159
id: toolTitle,

src-ts/tools/learn/tca-certificate/user-certificate/UserCertificate.tsx renamed to src-ts/tools/learn/tca-certificate/user-certificate/UserTCACertificate.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import { Dispatch, FC, MutableRefObject, SetStateAction, useEffect, useLayoutEffect, useRef, useState } from 'react'
2-
import { Params, useParams, useSearchParams } from 'react-router-dom'
1+
import { Dispatch, FC, MutableRefObject, SetStateAction, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
2+
import { NavigateFunction, Params, useNavigate, useParams, useSearchParams } from 'react-router-dom'
33

44
import {
55
LoadingSpinner,
66
profileGetPublicAsync,
77
UserProfile,
88
} from '../../../../lib'
9-
import { getViewStyleParamKey } from '../../learn.routes'
9+
import { getTCACertificationPath, getViewStyleParamKey } from '../../learn.routes'
1010
import { CertificateView, CertificateViewStyle } from '../certificate-view'
1111

12-
import styles from './UserCertificate.module.scss'
12+
import styles from './UserTCACertificate.module.scss'
1313

14-
const UserCertificate: FC<{}> = () => {
14+
const UserTCACertificate: FC<{}> = () => {
1515

16+
const navigate: NavigateFunction = useNavigate()
1617
const wrapElRef: MutableRefObject<HTMLElement | any> = useRef()
1718
const routeParams: Params<string> = useParams()
1819
const [queryParams]: [URLSearchParams, any] = useSearchParams()
@@ -23,9 +24,10 @@ const UserCertificate: FC<{}> = () => {
2324
] = useState()
2425
const [profileReady, setProfileReady]: [boolean, Dispatch<SetStateAction<boolean>>] = useState<boolean>(false)
2526

26-
const providerParam: string = routeParams.provider ?? ''
2727
const certificationParam: string = routeParams.certification ?? ''
2828

29+
const tcaCertificationPath: string = getTCACertificationPath(certificationParam)
30+
2931
useEffect(() => {
3032
if (routeParams.memberHandle) {
3133
profileGetPublicAsync(routeParams.memberHandle)
@@ -50,6 +52,10 @@ const UserCertificate: FC<{}> = () => {
5052
el.classList.add(styles['full-screen-cert'])
5153
})
5254

55+
const navigateToCertification: () => void = useCallback(() => {
56+
navigate(tcaCertificationPath)
57+
}, [tcaCertificationPath, navigate])
58+
5359
return (
5460
<>
5561
<LoadingSpinner hide={profileReady} />
@@ -59,8 +65,7 @@ const UserCertificate: FC<{}> = () => {
5965
<CertificateView
6066
certification={certificationParam}
6167
profile={profile}
62-
provider={providerParam}
63-
onCertificationNotCompleted={() => { }}
68+
onCertificationNotCompleted={navigateToCertification}
6469
hideActions
6570
viewStyle={queryParams.get(getViewStyleParamKey()) as CertificateViewStyle}
6671
/>
@@ -70,4 +75,4 @@ const UserCertificate: FC<{}> = () => {
7075
)
7176
}
7277

73-
export default UserCertificate
78+
export default UserTCACertificate
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default as UserCertificate } from './UserCertificate'
1+
export { default as UserTCACertificate } from './UserTCACertificate'

0 commit comments

Comments
 (0)