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'
3
3
4
4
import {
5
5
LoadingSpinner ,
6
6
profileGetPublicAsync ,
7
7
UserProfile ,
8
8
} from '../../../../lib'
9
- import { getViewStyleParamKey } from '../../learn.routes'
9
+ import { getTCACertificationPath , getViewStyleParamKey } from '../../learn.routes'
10
10
import { CertificateView , CertificateViewStyle } from '../certificate-view'
11
11
12
- import styles from './UserCertificate .module.scss'
12
+ import styles from './UserTCACertificate .module.scss'
13
13
14
- const UserCertificate : FC < { } > = ( ) => {
14
+ const UserTCACertificate : FC < { } > = ( ) => {
15
15
16
+ const navigate : NavigateFunction = useNavigate ( )
16
17
const wrapElRef : MutableRefObject < HTMLElement | any > = useRef ( )
17
18
const routeParams : Params < string > = useParams ( )
18
19
const [ queryParams ] : [ URLSearchParams , any ] = useSearchParams ( )
@@ -23,9 +24,10 @@ const UserCertificate: FC<{}> = () => {
23
24
] = useState ( )
24
25
const [ profileReady , setProfileReady ] : [ boolean , Dispatch < SetStateAction < boolean > > ] = useState < boolean > ( false )
25
26
26
- const providerParam : string = routeParams . provider ?? ''
27
27
const certificationParam : string = routeParams . certification ?? ''
28
28
29
+ const tcaCertificationPath : string = getTCACertificationPath ( certificationParam )
30
+
29
31
useEffect ( ( ) => {
30
32
if ( routeParams . memberHandle ) {
31
33
profileGetPublicAsync ( routeParams . memberHandle )
@@ -50,6 +52,10 @@ const UserCertificate: FC<{}> = () => {
50
52
el . classList . add ( styles [ 'full-screen-cert' ] )
51
53
} )
52
54
55
+ const navigateToCertification : ( ) => void = useCallback ( ( ) => {
56
+ navigate ( tcaCertificationPath )
57
+ } , [ tcaCertificationPath , navigate ] )
58
+
53
59
return (
54
60
< >
55
61
< LoadingSpinner hide = { profileReady } />
@@ -59,8 +65,7 @@ const UserCertificate: FC<{}> = () => {
59
65
< CertificateView
60
66
certification = { certificationParam }
61
67
profile = { profile }
62
- provider = { providerParam }
63
- onCertificationNotCompleted = { ( ) => { } }
68
+ onCertificationNotCompleted = { navigateToCertification }
64
69
hideActions
65
70
viewStyle = { queryParams . get ( getViewStyleParamKey ( ) ) as CertificateViewStyle }
66
71
/>
@@ -70,4 +75,4 @@ const UserCertificate: FC<{}> = () => {
70
75
)
71
76
}
72
77
73
- export default UserCertificate
78
+ export default UserTCACertificate
0 commit comments