55 ReactNode ,
66 SetStateAction ,
77 useCallback ,
8+ useLayoutEffect ,
89 useRef ,
910 useState ,
1011} from 'react'
@@ -34,7 +35,7 @@ import {
3435 useTCAShareCertificateModal ,
3536} from '..'
3637import { getTCACertificationPath , getUserTCACertificateSsr } from '../../learn.routes'
37- import { clearFCCCertificationTitle } from '../functions'
38+ import { clearFCCCertificationTitle , hideSiblings } from '../functions'
3839import { EnvironmentConfig } from '../../../../config'
3940
4041import { CertificateModal } from './certificate-modal'
@@ -64,6 +65,7 @@ export interface HiringManagerViewProps {
6465
6566const HiringManagerView : FC < HiringManagerViewProps > = ( props : HiringManagerViewProps ) => {
6667 const certificateElRef : MutableRefObject < HTMLDivElement | any > = useRef ( )
68+ const wrapElRef : MutableRefObject < HTMLElement | any > = useRef ( )
6769
6870 const [ certPreviewModalIsOpen , setCertPreviewModalIsOpen ] : [ boolean , Dispatch < SetStateAction < boolean > > ]
6971 = useState < boolean > ( false )
@@ -89,6 +91,8 @@ const HiringManagerView: FC<HiringManagerViewProps> = (props: HiringManagerViewP
8991 )
9092 const shareModal : TCAShareCertificateModalData = useTCAShareCertificateModal ( ssrCertUrl )
9193
94+ const renderShareActions : boolean = props . isOwner && ! props . isModalView
95+
9296 const getCertificateCanvas : ( ) => Promise < HTMLCanvasElement | void >
9397 = useCertificateCanvas ( certificateElRef )
9498
@@ -198,29 +202,31 @@ const HiringManagerView: FC<HiringManagerViewProps> = (props: HiringManagerViewP
198202 < div className = { styles . heroCert } >
199203 { renderTCACertificatePreview ( certificateElRef ) }
200204
201- < div className = { styles . certActionBtns } >
202- < ActionButton
203- icon = { < IconOutline . ZoomInIcon /> }
204- className = { classNames ( styles . certZoomBtn , styles . certActionBtn ) }
205- onClick = { handleShowCertPreviewModal }
206- />
207- { props . isOwner && (
208- < >
209- < ActionButton
210- className = { classNames ( 'desktop-hide' , styles . certActionBtn ) }
211- icon = { < IconOutline . PrinterIcon /> }
212- onClick = { handlePrint }
213- />
214- < ActionButton
215- className = { classNames ( 'desktop-hide' , styles . certActionBtn ) }
216- icon = { < IconOutline . DownloadIcon /> }
217- onClick = { handleDownload }
218- />
219- </ >
220- ) }
221- </ div >
205+ { ! props . isModalView && (
206+ < div className = { styles . certActionBtns } >
207+ < ActionButton
208+ icon = { < IconOutline . ZoomInIcon /> }
209+ className = { classNames ( styles . certZoomBtn , styles . certActionBtn ) }
210+ onClick = { handleShowCertPreviewModal }
211+ />
212+ { renderShareActions && (
213+ < >
214+ < ActionButton
215+ className = { classNames ( 'desktop-hide' , styles . certActionBtn ) }
216+ icon = { < IconOutline . PrinterIcon /> }
217+ onClick = { handlePrint }
218+ />
219+ < ActionButton
220+ className = { classNames ( 'desktop-hide' , styles . certActionBtn ) }
221+ icon = { < IconOutline . DownloadIcon /> }
222+ onClick = { handleDownload }
223+ />
224+ </ >
225+ ) }
226+ </ div >
227+ ) }
222228 </ div >
223- { props . isOwner && (
229+ { renderShareActions && (
224230 < div className = { classNames ( 'mobile-hide' , styles . certActionBtns ) } >
225231 < ActionButton
226232 className = { styles . certActionBtn }
@@ -241,8 +247,19 @@ const HiringManagerView: FC<HiringManagerViewProps> = (props: HiringManagerViewP
241247 )
242248 }
243249
250+ useLayoutEffect ( ( ) => {
251+ const el : HTMLElement = wrapElRef . current
252+ if ( ! el || ! props . isModalView ) {
253+ return
254+ }
255+
256+ hideSiblings ( el . parentElement as HTMLElement )
257+ hideSiblings ( el . parentElement ?. parentElement as HTMLElement )
258+
259+ } )
260+
244261 return ! ! props . certification && ! ! props . userProfile ? (
245- < div >
262+ < div className = { props . isModalView ? styles . modalView : '' } ref = { wrapElRef } >
246263 { renderHero ( ) }
247264
248265 < ContentLayout
@@ -251,7 +268,7 @@ const HiringManagerView: FC<HiringManagerViewProps> = (props: HiringManagerViewP
251268 innerClass = { styles . innerContentWrap }
252269 >
253270 < div className = { styles . wrap } >
254- { props . isOwner && (
271+ { renderShareActions && (
255272 < Button
256273 buttonStyle = 'primary'
257274 icon = { IconOutline . ShareIcon }
@@ -278,24 +295,28 @@ const HiringManagerView: FC<HiringManagerViewProps> = (props: HiringManagerViewP
278295 expandCount = { props . certification ?. skills ?. length ?? 0 }
279296 />
280297
281- < Button
282- buttonStyle = 'secondary'
283- label = { props . isOwner ? 'View your Topcoder profile' : 'View full Topcoder profile' }
284- url = { myProfileLink }
285- target = '_blank'
286- className = { styles . shareBtn }
287- />
298+ { ! props . isModalView && (
299+ < Button
300+ buttonStyle = 'secondary'
301+ label = { props . isOwner ? 'View your Topcoder profile' : 'View full Topcoder profile' }
302+ url = { myProfileLink }
303+ target = '_blank'
304+ className = { styles . shareBtn }
305+ />
306+ ) }
288307 </ div >
289308 </ div >
290309
291310 { renderCoursesGridItems ( ) }
292311
293- < Button
294- className = { styles . detailsBtn }
295- buttonStyle = 'link'
296- label = 'Certification details'
297- route = { certificationDetailsLink }
298- />
312+ { ! props . isModalView && (
313+ < Button
314+ className = { styles . detailsBtn }
315+ buttonStyle = 'link'
316+ label = 'Certification details'
317+ route = { certificationDetailsLink }
318+ />
319+ ) }
299320 </ div >
300321 </ ContentLayout >
301322 { shareModal . modal }
0 commit comments