Skip to content

Commit 2d6192b

Browse files
authored
Merge pull request #610 from topcoder-platform/TCA-1279_profile-page-ifr
TCA-1279 - hide header & footer for hiring manager view in modal mode -> dev
2 parents 7e60ebc + 490526c commit 2d6192b

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src-ts/tools/learn/learn-lib/hiring-manager-view/HiringManagerView.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
ReactNode,
66
SetStateAction,
77
useCallback,
8-
useLayoutEffect,
98
useMemo,
109
useRef,
1110
useState,
@@ -36,7 +35,7 @@ import {
3635
useTCAShareCertificateModal,
3736
} from '..'
3837
import { getTCACertificationPath, getUserTCACertificateSsr } from '../../learn.routes'
39-
import { clearFCCCertificationTitle, hideSiblings } from '../functions'
38+
import { clearFCCCertificationTitle } from '../functions'
4039
import { EnvironmentConfig } from '../../../../config'
4140

4241
import { CertificateModal } from './certificate-modal'
@@ -68,7 +67,6 @@ export interface HiringManagerViewProps {
6867
// eslint-disable-next-line complexity
6968
const HiringManagerView: FC<HiringManagerViewProps> = (props: HiringManagerViewProps) => {
7069
const certificateElRef: MutableRefObject<HTMLDivElement | any> = useRef()
71-
const wrapElRef: MutableRefObject<HTMLElement | any> = useRef()
7270

7371
const [certPreviewModalIsOpen, setCertPreviewModalIsOpen]: [boolean, Dispatch<SetStateAction<boolean>>]
7472
= useState<boolean>(false)
@@ -253,19 +251,8 @@ const HiringManagerView: FC<HiringManagerViewProps> = (props: HiringManagerViewP
253251
)
254252
}
255253

256-
useLayoutEffect(() => {
257-
const el: HTMLElement = wrapElRef.current
258-
if (!el || !props.isModalView) {
259-
return
260-
}
261-
262-
hideSiblings(el.parentElement as HTMLElement)
263-
hideSiblings(el.parentElement?.parentElement as HTMLElement)
264-
265-
})
266-
267254
return !!props.certification && !!props.userProfile ? (
268-
<div className={props.isModalView ? styles.modalView : ''} ref={wrapElRef}>
255+
<div className={props.isModalView ? styles.modalView : ''}>
269256
{renderHero()}
270257

271258
<ContentLayout

src-ts/tools/learn/tca-certificate/user-certification-view/UserCertificationViewBase.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
MutableRefObject,
55
SetStateAction,
66
useEffect,
7+
useLayoutEffect,
78
useRef,
89
useState,
910
} from 'react'
@@ -16,6 +17,7 @@ import {
1617
} from '../../../../lib'
1718
import {
1819
CertificatePageLayout,
20+
hideSiblings,
1921
HiringManagerView,
2022
PageTitle,
2123
TCACertification,
@@ -34,6 +36,7 @@ interface UserCertificationViewBaseProps {
3436

3537
const UserCertificationViewBase: FC<UserCertificationViewBaseProps> = (props: UserCertificationViewBaseProps) => {
3638
const [queryParams]: [URLSearchParams, any] = useSearchParams()
39+
const wrapElRef: MutableRefObject<HTMLElement | any> = useRef()
3740

3841
const tcaCertificationPath: string = getTCACertificationPath(`${props.certification?.dashedName}`)
3942
const certificateElRef: MutableRefObject<HTMLDivElement | any> = useRef()
@@ -55,6 +58,15 @@ const UserCertificationViewBase: FC<UserCertificationViewBaseProps> = (props: Us
5558
.then(verified => setIsMemberVerified(verified))
5659
}, [props.enrollment])
5760

61+
useLayoutEffect(() => {
62+
const el: HTMLElement = wrapElRef.current
63+
if (!el || !isModalView) {
64+
return
65+
}
66+
67+
hideSiblings(el.parentElement as HTMLElement)
68+
}, [isModalView])
69+
5870
return (
5971
<>
6072
<PageTitle>
@@ -74,8 +86,8 @@ const UserCertificationViewBase: FC<UserCertificationViewBaseProps> = (props: Us
7486
</CertificatePageLayout>
7587
)}
7688

77-
{props.profile && props.certification && props.enrollment && (
78-
<div className='full-height-frame'>
89+
<div className='full-height-frame' ref={wrapElRef}>
90+
{props.profile && props.certification && props.enrollment && (
7991
<HiringManagerView
8092
certification={props.certification}
8193
completedAt={(props.enrollment.completedAt ?? undefined) as string}
@@ -88,8 +100,8 @@ const UserCertificationViewBase: FC<UserCertificationViewBaseProps> = (props: Us
88100
isPreview={props.isPreview}
89101
isModalView={isModalView}
90102
/>
91-
</div>
92-
)}
103+
)}
104+
</div>
93105
</>
94106
)
95107
}

0 commit comments

Comments
 (0)