Skip to content

Commit 4f9718a

Browse files
authored
Merge pull request #472 from topcoder-platform/TCA-935-homepage-API-integration
TCA-935 homepage integration init
2 parents 996a609 + 4dd0be7 commit 4f9718a

31 files changed

+218
-51
lines changed

src-ts/tools/learn/certification-details/CertificationDetailsPage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FC, ReactNode, useContext } from 'react'
22
import { Params, useParams } from 'react-router-dom'
33

44
import { PageSubheaderPortalId } from '../../../config'
5-
import { TCACertificationsProviderData, useGetTCACertificationMOCK, useLearnBreadcrumb, WaveHero } from '../learn-lib'
5+
import { TCACertificationProviderData, useGetTCACertificationMOCK, useLearnBreadcrumb, WaveHero } from '../learn-lib'
66
import {
77
Breadcrumb,
88
BreadcrumbItemModel,
@@ -39,9 +39,9 @@ const CertificationDetailsPage: FC<{}> = () => {
3939
const { initialized: profileReady }: ProfileContextData = useContext(profileContext)
4040

4141
const {
42-
certifications: [certification],
42+
certification,
4343
ready: certificateReady,
44-
}: TCACertificationsProviderData = useGetTCACertificationMOCK(dashedName as string)
44+
}: TCACertificationProviderData = useGetTCACertificationMOCK(dashedName as string)
4545

4646
const ready: boolean = profileReady && certificateReady
4747

@@ -100,8 +100,8 @@ const CertificationDetailsPage: FC<{}> = () => {
100100
<WaveHero
101101
title={(
102102
<HeroTitle
103+
certification={certification}
103104
certTitle={certification.title}
104-
providers={certification.providers}
105105
/>
106106
)}
107107
theme='grey'

src-ts/tools/learn/certification-details/certification-details-sidebar/CertificationDetailsSidebar.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { FC, ReactNode } from 'react'
22
import classNames from 'classnames'
33

44
import { Button, IconOutline, IconSolid, Tooltip } from '../../../../lib'
5-
import { ProvidersLogoList } from '../providers-logo-list'
6-
import { LearnLevelIcon, TCACertification } from '../../learn-lib'
5+
import { LearnLevelIcon, ProvidersLogoList, TCACertification } from '../../learn-lib'
76

87
import img from './certificate-placeholder.jpg'
98
import styles from './CertificationDetailsSidebar.module.scss'

src-ts/tools/learn/certification-details/hero-title/HeroTitle.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
import { FC } from 'react'
22

3-
import { DevCertBadgeSvg, TCACertification } from '../../learn-lib'
4-
import { ProvidersLogoList } from '../providers-logo-list'
3+
import { TCACertBadge, TCACertification } from '../../learn-lib'
4+
import { ProvidersLogoList } from '../../learn-lib/providers-logo-list'
55

66
import styles from './HeroTitle.module.scss'
77

88
interface HeroTitleProps {
9+
certification: TCACertification
910
certTitle: string
10-
providers: TCACertification['providers']
1111
}
1212

1313
const HeroTitle: FC<HeroTitleProps> = (props: HeroTitleProps) => (
1414
<div className={styles.wrap}>
15-
<DevCertBadgeSvg />
15+
<TCACertBadge
16+
learnerLevel={props.certification.learnerLevel}
17+
certificationCategory={props.certification.certificationCategory}
18+
/>
1619
<div className={styles.text}>
1720
<h1 className={styles.title}>
1821
{props.certTitle}
1922
</h1>
2023
<ProvidersLogoList
2124
label='Content from'
22-
providers={props.providers}
25+
providers={props.certification.providers}
2326
/>
2427
</div>
2528
</div>

src-ts/tools/learn/certification-details/providers-logo-list/providers-logo-map.tsx

Lines changed: 0 additions & 12 deletions
This file was deleted.

src-ts/tools/learn/learn-lib/data-providers/tca-certifications-provider/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ export * from './tca-certificate-status-type'
44
export * from './tca-certificate-level-type'
55
export * from './tca-certification.model'
66
export * from './tca-provider-type'
7+
export * from './tca-certification-provider.model-base'
8+
export * from './tca-certification-provider.model'
9+
export * from './tca-certification-resource.model'
10+
export * from './tca-certification-resourceable.type'
11+
export * from './tca-certification-category.model'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { TCAProviderType } from './tca-provider-type'
2+
3+
export interface TCACertificationProviderBase {
4+
id: number
5+
name: TCAProviderType
6+
description: string
7+
url: string
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { TCACertificationProviderBase } from './tca-certification-provider.model-base'
2+
import { TCACertificationResource } from './tca-certification-resource.model'
3+
4+
export interface TCACertificationProvider extends TCACertificationProviderBase {
5+
attributionStatement: string
6+
CertificationResource: TCACertificationResource
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { TCACertificationResourceable } from './tca-certification-resourceable.type'
2+
3+
export interface TCACertificationResource {
4+
id: number
5+
topcoderCertificationId: number
6+
resourceProviderId: number
7+
resourceableId: number
8+
resourceableType: TCACertificationResourceable
9+
displayOrder: number
10+
completionOrder: number
11+
resourceDescription: string
12+
resourceTitle: string
13+
createdAt: Date
14+
updatedAt: Date
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type TCACertificationResourceable = 'FreeCodeCampCertification'
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
import { TCACertificationLearnLevel } from './tca-certificate-level-type'
22
import { TCACertificationStatus } from './tca-certificate-status-type'
33
import { TCACertificationCategory } from './tca-certification-category.model'
4-
import { TcaProviderType } from './tca-provider-type'
4+
import { TCACertificationProvider } from './tca-certification-provider.model'
5+
import { TCACertificationProviderBase } from './tca-certification-provider.model-base'
6+
import { TCACertificationResource } from './tca-certification-resource.model'
57

68
export interface TCACertification {
79
id: number
810
title: string
9-
certificationCategoryId: string
10-
coursesCount: number
1111
dashedName: string
1212
description: string
1313
introText: string
1414
estimatedCompletionTime: number
15+
status: TCACertificationStatus
16+
sequentialCourses: boolean
1517
learnerLevel: TCACertificationLearnLevel
16-
certificationCategory: TCACertificationCategory
18+
certificationCategoryId: string
1719
stripeProductId?: string
1820
skills: string[]
1921
learningOutcomes: string[]
2022
prerequisites: string[]
2123
createdAt: Date
2224
updatedAt: Date
23-
providers: Array<TcaProviderType>
24-
sequentialCourses: boolean
25-
status: TCACertificationStatus
25+
certificationResources: Array<TCACertificationResource>
26+
certificationCategory: TCACertificationCategory
27+
resourceProviders: Array<TCACertificationProvider>
28+
coursesCount: number
29+
providers: Array<TCACertificationProviderBase>
2630
}

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ const TCACertificationMock: TCACertification[] = [{
2626
status: 'active',
2727
certificationCategoryId: '',
2828
skills: ['HTML', 'CSS', 'JavaScript', 'HTML', 'CSS', 'JavaScript', 'HTML', 'CSS', 'JavaScript', 'HTML', 'CSS', 'JavaScript', 'HTML', 'CSS', 'JavaScript'],
29+
providers: [{
30+
"id": 1,
31+
"name": "freeCodeCamp",
32+
"description": "Free courses about programming and some such",
33+
"url": "freeCodeCamp.org"
34+
}],
35+
coursesCount: 5,
36+
learningOutcomes: ['HTML', 'CSS', 'JavaScript'],
37+
certificationCategory: {
38+
"track": "DEV",
39+
},
2940
},
3041
{
3142
id: 2,
@@ -38,6 +49,17 @@ const TCACertificationMock: TCACertification[] = [{
3849
learnerLevel: 'Expert',
3950
certificationCategoryId: '',
4051
skills: ['Python', 'TensorFlow', 'JSON'],
52+
providers: [{
53+
"id": 1,
54+
"name": "freeCodeCamp",
55+
"description": "Free courses about programming and some such",
56+
"url": "freeCodeCamp.org"
57+
}],
58+
coursesCount: 1,
59+
learningOutcomes: ['Python', 'TensorFlow', 'JSON'],
60+
certificationCategory: {
61+
"track": "DATASCIENCE",
62+
},
4163
}]
4264

4365
export function useGetAllTCACertifications(
@@ -91,7 +113,7 @@ export function useGetTCACertificationMOCK(
91113
certification: string,
92114
): TCACertificationProviderData {
93115

94-
const data: TCACertification | undefined = find(TCACertificationMock, { dashedName: certification })
116+
const data: TCACertification = find(TCACertificationMock, { dashedName: certification })
95117

96118
return {
97119
certification: data,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export type TcaProviderType = 'freecodecamp' | 'topcoder'
1+
export type TCAProviderType = 'freeCodeCamp' | 'Topcoder'

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export * from './learn-breadcrumb-provider'
99
export * from './learn-level-icon'
1010
export * from './learn-swr'
1111
export * from './my-course-card'
12+
export * from './providers-logo-list'
1213
export * from './svgs'
14+
export * from './tca-cert-badge'
1315
export * from './use-certificate-canvas-hook'
1416
export * from './use-certificate-print-hook'
1517
export * from './use-certificate-scaling-hook'

src-ts/tools/learn/certification-details/providers-logo-list/ProvidersLogoList.tsx renamed to src-ts/tools/learn/learn-lib/providers-logo-list/ProvidersLogoList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FC, Fragment } from 'react'
22
import classNames from 'classnames'
33

4-
import { TCACertification } from '../../learn-lib'
4+
import { TCACertification } from '..'
55

66
import { getProviderLogo } from './providers-logo-map'
77
import styles from './ProvidersLogoList.module.scss'
@@ -19,7 +19,7 @@ const ProvidersLogoList: FC<ProvidersLogoListProps> = (props: ProvidersLogoListP
1919
</span>
2020
<div>
2121
{props.providers.map(p => (
22-
<Fragment key={p}>{getProviderLogo(p)}</Fragment>
22+
<Fragment key={`${p.id}-${p.name}`}>{getProviderLogo(p.name)}</Fragment>
2323
))}
2424
</div>
2525
</div>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ReactNode } from 'react'
2+
3+
import { FccLogoBlackSvg, TcLogoSvg } from '../svgs'
4+
import { TCAProviderType } from '../data-providers'
5+
6+
export const providersLogoMap: {[key in TCAProviderType]: ReactNode} = {
7+
freeCodeCamp: <FccLogoBlackSvg />,
8+
Topcoder: <TcLogoSvg />,
9+
}
10+
11+
export function getProviderLogo(provider: TCAProviderType): ReactNode {
12+
return providersLogoMap[provider]
13+
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ export { ReactComponent as LearningHat } from './learning-hat.svg'
22
export { ReactComponent as CertIcon } from './cert-icon.svg'
33
export { ReactComponent as CourseIcon } from './course-icon.svg'
44
export { ReactComponent as CrowdIcon } from './crowd-icon.svg'
5-
export { ReactComponent as DevCertBadgeSvg } from './dev-cert-badge.svg'
65
export { ReactComponent as TcLogoSvg } from './tc-logo.svg'
76
export { ReactComponent as FccLogoBlackSvg } from './vendor-fcc-logo-black.svg'
87
export { ReactComponent as IconCertifSvg } from './icon-certif.svg'
8+
export { ReactComponent as DSCertBadge1Svg } from './ds-cert-badge-1.svg'
9+
export { ReactComponent as DSCertBadge2Svg } from './ds-cert-badge-2.svg'
10+
export { ReactComponent as DSCertBadge3Svg } from './ds-cert-badge-3.svg'
11+
export { ReactComponent as WebDevCertBadge1Svg } from './web-dev-cert-badge-1.svg'
12+
export { ReactComponent as WebDevCertBadge2Svg } from './web-dev-cert-badge-2.svg'
13+
export { ReactComponent as WebDevCertBadge3Svg } from './web-dev-cert-badge-3.svg'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@import '../../../../lib/styles/includes';
2+
3+
.tcaBadge {
4+
@include ltemd {
5+
width: 60px;
6+
height: 56px;
7+
}
8+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { FC } from 'react'
2+
import {
3+
DSCertBadge1Svg,
4+
DSCertBadge2Svg,
5+
DSCertBadge3Svg,
6+
TCACertificationCategory,
7+
TCACertificationLearnLevel,
8+
WebDevCertBadge1Svg,
9+
WebDevCertBadge2Svg,
10+
WebDevCertBadge3Svg,
11+
} from '..'
12+
import styles from './TCACertBadge.module.scss'
13+
14+
interface TCACertBadgeProps {
15+
learnerLevel: TCACertificationLearnLevel
16+
certificationCategory: TCACertificationCategory
17+
}
18+
19+
const badgesMap: any = {
20+
DATASCIENCE: {
21+
Beginner: <DSCertBadge1Svg className={styles.tcaBadge} />,
22+
Expert: <DSCertBadge3Svg className={styles.tcaBadge} />,
23+
Intermediate: <DSCertBadge2Svg className={styles.tcaBadge} />,
24+
},
25+
DEV: {
26+
Beginner: <WebDevCertBadge1Svg className={styles.tcaBadge} />,
27+
Expert: <WebDevCertBadge3Svg className={styles.tcaBadge} />,
28+
Intermediate: <WebDevCertBadge2Svg className={styles.tcaBadge} />,
29+
},
30+
}
31+
32+
const TCACertBadge: FC<TCACertBadgeProps>
33+
= (props: TCACertBadgeProps): JSX.Element => badgesMap[props.certificationCategory.track][props.learnerLevel]
34+
35+
export default TCACertBadge
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as TCACertBadge } from './TCACertBadge'

src-ts/tools/learn/welcome/tc-certifications/TCCertifications.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,9 @@
4141
display: grid;
4242
grid-template-columns: 1fr 1fr;
4343
gap: $space-xxl;
44+
45+
@include ltemd {
46+
grid-template-columns: 1fr;
47+
}
4448
}
4549
}

src-ts/tools/learn/welcome/tc-certifications/TCCertifications.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface TCCertificationsProps {
1313
const TCCertifications: FC<TCCertificationsProps> = (props: TCCertificationsProps) => {
1414
const renderListCard: (certification: TCACertification) => ReactNode
1515
= useCallback((certification: TCACertification) => (
16-
<TCCertCard certification={certification} />
16+
<TCCertCard certification={certification} key={certification.dashedName} />
1717
), [])
1818

1919
return (

src-ts/tools/learn/welcome/tc-certifications/cert-card/TCCertCard.module.scss

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
display: flex;
55
flex-direction: column;
66
background-color: $black-5;
7-
padding: $space-xxl $space-lg;
7+
padding: $space-xxxxl $space-xxl;
88
border-radius: 8px;
99

1010
.cardHeader {
@@ -14,6 +14,10 @@
1414
padding-bottom: $space-xxl;
1515
margin-bottom: $space-xxl;
1616

17+
@include ltemd {
18+
align-items: flex-start;
19+
}
20+
1721
.cardTitleWrap {
1822
display: flex;
1923
flex-direction: column;
@@ -50,7 +54,7 @@
5054
.skills {
5155
display: flex;
5256
flex-wrap: wrap;
53-
margin: $space-sm 0;
57+
margin-top: $space-sm;
5458

5559
>div {
5660
margin-right: $space-sm;
@@ -66,12 +70,20 @@
6670
display: flex;
6771
align-items: center;
6872
}
73+
74+
.cardBottom {
75+
margin-top: $space-xxl;
76+
77+
@include ltemd {
78+
margin-top: $space-xl;
79+
}
80+
}
6981
}
7082

7183
.infoText {
7284
font-style: italic;
7385
color: $black-60;
74-
margin-right: $space-lg;
86+
margin-right: $space-sm;
7587

7688
&:last-child {
7789
margin-right: 0;

0 commit comments

Comments
 (0)