Skip to content

Commit 0ed682a

Browse files
authored
Merge pull request #510 from topcoder-platform/TCA-1018
TCA 1018
2 parents eced16a + 357b9ff commit 0ed682a

File tree

6 files changed

+106
-34
lines changed

6 files changed

+106
-34
lines changed

src-ts/tools/learn/course-certificate/user-certificate/UserCertificate.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from '../../../../lib'
99
import { getViewStyleParamKey } from '../../learn.routes'
1010
import { CertificateView, CertificateViewStyle } from '../certificate-view'
11+
import { hideSiblings } from '../../learn-lib/functions'
1112

1213
import styles from './UserCertificate.module.scss'
1314

@@ -26,14 +27,6 @@ const UserCertificate: FC<{}> = () => {
2627
const providerParam: string = routeParams.provider ?? ''
2728
const certificationParam: string = routeParams.certification ?? ''
2829

29-
function hideSiblings(el: HTMLElement): void {
30-
[].forEach.call(el.parentElement?.children ?? [], (c: HTMLElement) => {
31-
if (c !== el) {
32-
Object.assign(c.style, { display: 'none' })
33-
}
34-
})
35-
}
36-
3730
useEffect(() => {
3831
if (routeParams.memberHandle) {
3932
profileGetPublicAsync(routeParams.memberHandle)

src-ts/tools/learn/learn-lib/data-providers/tca-certifications-provider/tca-certification-enrollment/tca-enrollment-provider.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ import useSWR, { SWRConfiguration, SWRResponse } from 'swr'
22

33
import { learnUrlGet } from '../../../functions'
44
import { useSwrCache } from '../../../learn-swr'
5-
import { TCACertificationEnrollmentProviderData } from '../tca-certification-progress'
5+
import { TCACertificationEnrollmentBase } from '../tca-certification-enrollment-base.model'
6+
7+
export interface TCACertificationEnrollmentProviderData {
8+
enrollment: TCACertificationEnrollmentBase
9+
error: boolean
10+
loading: boolean
11+
ready: boolean
12+
}
613

714
export function useTCACertificationEnrollment(
815
id: string, // note id | completionUuid both are supported by the API
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function hideSiblings(el: HTMLElement): void {
2+
[].forEach.call(el.parentElement?.children ?? [], (c: HTMLElement) => {
3+
if (c !== el) {
4+
Object.assign(c.style, { display: 'none' })
5+
}
6+
})
7+
}

src-ts/tools/learn/learn-lib/functions/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ export {
55
postAsync as learnXhrPostAsync,
66
putAsync as learnXhrPutAsync,
77
} from './learn-xhr.functions'
8+
export { hideSiblings } from './hide-siblings'

src-ts/tools/learn/tca-certificate/validate-certificate/ValidateTCACertificate.module.scss

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
padding-top: calc($space-mx * 2);
88
color: $tc-white;
99

10-
@include ltemd {
10+
@include ltelg {
1111
padding-top: $space-mx;
1212
}
1313

@@ -34,7 +34,7 @@
3434
overflow: hidden;
3535
justify-content: center;
3636

37-
@include ltemd {
37+
@include ltelg {
3838
flex-direction: column;
3939
}
4040

@@ -109,7 +109,7 @@
109109
flex: 1 1 auto;
110110
min-width: 360px;
111111
max-width: 480px;
112-
@include ltemd {
112+
@include ltelg {
113113
max-width: none;
114114
}
115115
}
@@ -121,7 +121,7 @@
121121
flex-direction: column;
122122
margin-top: calc($space-mx + $space-mx);
123123

124-
@include ltemd {
124+
@include ltelg {
125125
margin-top: $space-mx;
126126
}
127127

@@ -148,7 +148,7 @@
148148
gap: $space-xl;
149149
margin-top: $space-xxl;
150150

151-
@include ltemd {
151+
@include ltelg {
152152
grid-template-columns: 1fr;
153153
}
154154

@@ -167,4 +167,46 @@
167167
}
168168
}
169169
}
170+
}
171+
172+
.modalView {
173+
.hero {
174+
padding-top: $space-lg;
175+
max-height: 360px;
176+
177+
@include ltesm {
178+
max-height: none;
179+
}
180+
181+
182+
.heroInner {
183+
margin-bottom: 0;
184+
flex-direction: row;
185+
186+
@include ltesm {
187+
flex-direction: column;
188+
}
189+
190+
.heroLeft {
191+
transform: scale(0.67);
192+
transform-origin: 0 0;
193+
194+
@include ltesm {
195+
transform: none;
196+
}
197+
}
198+
}
199+
}
200+
201+
.contentOuter {
202+
max-width: none;
203+
204+
>div {
205+
max-width: none !important;
206+
}
207+
208+
.courses {
209+
margin-bottom: 0;
210+
}
211+
}
170212
}

src-ts/tools/learn/tca-certificate/validate-certificate/ValidateTCACertificate.tsx

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
import { Dispatch, FC, ReactNode, SetStateAction, useEffect, useMemo, useState } from 'react'
2-
import { Params, useParams } from 'react-router-dom'
1+
import {
2+
Dispatch,
3+
FC,
4+
MutableRefObject,
5+
ReactNode,
6+
SetStateAction,
7+
useEffect,
8+
useLayoutEffect,
9+
useMemo, useRef,
10+
useState,
11+
} from 'react'
12+
import { Params, useParams, useSearchParams } from 'react-router-dom'
313
import classNames from 'classnames'
414

515
import {
@@ -23,12 +33,18 @@ import {
2333
} from '../../learn-lib'
2434
import { EnvironmentConfig } from '../../../../config'
2535
import { getTCACertificationValidationUrl } from '../../learn.routes'
36+
import { hideSiblings } from '../../learn-lib/functions'
2637

2738
import styles from './ValidateTCACertificate.module.scss'
2839

2940
const ValidateTCACertificate: FC<{}> = () => {
3041

42+
const wrapElRef: MutableRefObject<HTMLElement | any> = useRef()
43+
3144
const routeParams: Params<string> = useParams()
45+
const [queryParams]: [URLSearchParams, any] = useSearchParams()
46+
47+
const isModalView: boolean = queryParams.get('view-style') === 'modal'
3248

3349
const [profile, setProfile]: [
3450
UserProfile | undefined,
@@ -41,7 +57,7 @@ const ValidateTCACertificate: FC<{}> = () => {
4157
enrollment,
4258
ready: certReady,
4359
}: TCACertificationEnrollmentProviderData
44-
= useTCACertificationEnrollment(routeParams.completionUuid as string)
60+
= useTCACertificationEnrollment(routeParams.completionUuid as string)
4561

4662
const certification: TCACertification | undefined = enrollment?.topcoderCertification
4763

@@ -72,6 +88,17 @@ const ValidateTCACertificate: FC<{}> = () => {
7288
}
7389
}, [enrollment, setProfileReady])
7490

91+
useLayoutEffect(() => {
92+
const el: HTMLElement = wrapElRef.current
93+
if (!el || !isModalView) {
94+
return
95+
}
96+
97+
hideSiblings(el)
98+
hideSiblings(el.parentElement as HTMLElement)
99+
100+
})
101+
75102
function visitFullProfile(): void {
76103
window.open(`${EnvironmentConfig.TOPCODER_URLS.USER_PROFILE}/${profile?.handle}`, '_blank')
77104
}
@@ -81,14 +108,14 @@ const ValidateTCACertificate: FC<{}> = () => {
81108
<LoadingSpinner hide={profileReady && certReady} />
82109

83110
{profile && certification && (
84-
<div className='full-height-frame'>
111+
<div className={classNames('full-height-frame', isModalView ? styles.modalView : '')} ref={wrapElRef}>
85112
<div
86113
className={classNames(
87114
styles.hero,
88115
styles[`hero-${certification.certificationCategory?.track.toLowerCase() || 'dev'}`],
89116
)}
90117
>
91-
<ContentLayout>
118+
<ContentLayout outerClass={isModalView ? styles.contentOuter : ''}>
92119
<div className={styles.heroInner}>
93120
<div className={styles.heroLeft}>
94121
<div className={styles.member}>
@@ -132,20 +159,12 @@ const ValidateTCACertificate: FC<{}> = () => {
132159
completionUuid={routeParams.completionUuid}
133160
validateLink={validateLink}
134161
/>
135-
{/* <Certificate
136-
certification={certification}
137-
completedDate={enrollment?.completedAt as unknown as string}
138-
userName={enrollment?.userName}
139-
completionUuid={routeParams.completionUuid}
140-
validateLink={validateLink}
141-
viewStyle='small-container'
142-
/> */}
143162
</div>
144163
</div>
145164
</ContentLayout>
146165
</div>
147166

148-
<ContentLayout>
167+
<ContentLayout outerClass={isModalView ? styles.contentOuter : ''}>
149168
<div className={styles.wrap}>
150169
<h2>
151170
{'What '}
@@ -160,12 +179,15 @@ const ValidateTCACertificate: FC<{}> = () => {
160179
{coursesGridItems}
161180
</div>
162181
</div>
163-
164-
<Button
165-
buttonStyle='link'
166-
label='Visit Full Profile'
167-
onClick={visitFullProfile}
168-
/>
182+
{
183+
!isModalView && (
184+
<Button
185+
buttonStyle='link'
186+
label='Visit Full Profile'
187+
onClick={visitFullProfile}
188+
/>
189+
)
190+
}
169191
</div>
170192
</ContentLayout>
171193
</div>

0 commit comments

Comments
 (0)