1- import { FC , useLayoutEffect } from 'react'
1+ import { FC , MutableRefObject , useLayoutEffect , useRef } from 'react'
22import { NavigateFunction , Params , useNavigate , useParams , useSearchParams } from 'react-router-dom'
33
44import { LoadingSpinner } from '../../../../lib'
55import {
6+ hideSiblings ,
67 TCACertification ,
78 TCACertificationEnrollmentProviderData ,
89 useTCACertificationEnrollment ,
@@ -16,6 +17,8 @@ const UuidCertificationView: FC<{}> = () => {
1617 const routeParams : Params < string > = useParams ( )
1718 const [ queryParams ] : [ URLSearchParams , any ] = useSearchParams ( )
1819
20+ const elRef : MutableRefObject < HTMLElement | any > = useRef ( )
21+
1922 const {
2023 enrollment,
2124 error : enrollmentError ,
@@ -24,6 +27,7 @@ const UuidCertificationView: FC<{}> = () => {
2427 = useTCACertificationEnrollment ( routeParams . completionUuid as string )
2528
2629 const certification : TCACertification | undefined = enrollment ?. topcoderCertification
30+ const isModalView : boolean = queryParams . get ( 'view-style' ) === 'modal'
2731
2832 useLayoutEffect ( ( ) => {
2933 if ( enrollmentReady && enrollment ) {
@@ -37,9 +41,18 @@ const UuidCertificationView: FC<{}> = () => {
3741 }
3842 } , [ certification ?. dashedName , enrollment , enrollmentReady , navigate , queryParams ] )
3943
44+ useLayoutEffect ( ( ) => {
45+ const el : HTMLElement = elRef . current
46+ if ( ! el || ! isModalView ) {
47+ return
48+ }
49+
50+ hideSiblings ( el . parentElement as HTMLElement )
51+ } , [ isModalView ] )
52+
4053 return (
4154 < >
42- < LoadingSpinner hide = { enrollmentReady } />
55+ < LoadingSpinner hide = { enrollmentReady } ref = { elRef } />
4356 { enrollmentReady && enrollmentError && (
4457 < UserCertificationViewBase
4558 enrollment = { enrollment }
0 commit comments