Skip to content

Commit 6ca9882

Browse files
committed
TCA-768 - update user profile to support old api response
1 parent 39571e9 commit 6ca9882

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

src/shared/components/ProfilePage/TcaCertificates/index.jsx

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react';
1+
import React, { Fragment, useState } from 'react';
22
import PT from 'prop-types';
33

44
import './styles.scss';
@@ -20,25 +20,33 @@ const TcaCertificates = ({ certifications, courses, memberHandle }) => {
2020
Topcoder Academy
2121
</h3>
2222

23-
<h4 styleName="category-title">Certifications</h4>
24-
<List
25-
certificates={certifications}
26-
isVerified
27-
onClick={certificate => setShowCertificationCertificate(certificate)}
28-
renderIcon={enrollment => (
29-
<CertificationBadge
30-
type={enrollment.topcoderCertification.certificationCategory.track || 'DEV'}
31-
level={enrollment.topcoderCertification.learnerLevel || 'Beginner'}
23+
{certifications.length > 0 && (
24+
<Fragment>
25+
<h4 styleName="category-title">Certifications</h4>
26+
<List
27+
certificates={certifications}
28+
isVerified
29+
onClick={certificate => setShowCertificationCertificate(certificate)}
30+
renderIcon={enrollment => (
31+
<CertificationBadge
32+
type={enrollment.topcoderCertification.certificationCategory.track || 'DEV'}
33+
level={enrollment.topcoderCertification.learnerLevel || 'Beginner'}
34+
/>
35+
)}
3236
/>
33-
)}
34-
/>
35-
<h4 styleName="category-title">Courses</h4>
36-
<List
37-
certificates={courses}
38-
isVerified
39-
onClick={certificate => setShowCourseCertificate(certificate)}
40-
renderIcon={certificate => <CourseBadge type={certificate.certificationTrackType || 'DEV'} />}
41-
/>
37+
</Fragment>
38+
)}
39+
{courses.length > 0 && (
40+
<Fragment>
41+
<h4 styleName="category-title">Courses</h4>
42+
<List
43+
certificates={courses}
44+
isVerified
45+
onClick={certificate => setShowCourseCertificate(certificate)}
46+
renderIcon={certificate => <CourseBadge type={certificate.certificationTrackType || 'DEV'} />}
47+
/>
48+
</Fragment>
49+
)}
4250

4351
{ showCertificationCertificate && (
4452
<TcaCertificationCertificateModal

src/shared/containers/Profile.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ const mapStateToProps = (state, ownProps) => ({
210210
badges: state.page.profile[ownProps.match.params.handle]
211211
? state.page.profile[ownProps.match.params.handle].badges : {},
212212
tcAcademyCertifications: _.get(state.tcAcademy, 'certifications.enrollments', []),
213-
tcAcademyCourses: _.get(state.tcAcademy, 'certifications.courses', []),
213+
tcAcademyCourses: Array.isArray(state.tcAcademy.certifications)
214+
? state.tcAcademy.certifications
215+
: _.get(state.tcAcademy, 'certifications.courses', []),
214216
auth: {
215217
...state.auth,
216218
},

0 commit comments

Comments
 (0)