Skip to content

Commit 0994dc0

Browse files
Merge pull request #6563 from topcoder-platform/develop
Release v1.17.7
2 parents d7d5d2b + 13829af commit 0994dc0

File tree

2 files changed

+73
-30
lines changed
  • __tests__/shared/components/ProfilePage/__snapshots__
  • src/shared/components/ProfilePage/Header

2 files changed

+73
-30
lines changed

__tests__/shared/components/ProfilePage/__snapshots__/index.jsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`renders a full Profile correctly 1`] = `
55
className="src-shared-components-ProfilePage-___styles__outer-container___3in3p"
66
>
77
<div>
8-
<ProfileHeader
8+
<Connect(ProfileHeader)
99
info={
1010
Object {
1111
"competitionCountryCode": "USA",
@@ -717,7 +717,7 @@ exports[`renders an empty Profile correctly 1`] = `
717717
className="src-shared-components-ProfilePage-___styles__outer-container___3in3p"
718718
>
719719
<div>
720-
<ProfileHeader
720+
<Connect(ProfileHeader)
721721
info={
722722
Object {
723723
"competitionCountryCode": "USA",

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

Lines changed: 71 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@
33
*/
44
import React, { useEffect, useState } from 'react';
55
import PT from 'prop-types';
6+
import { connect } from 'react-redux';
67

8+
import { actions } from 'topcoder-react-lib';
79
import { isomorphy } from 'topcoder-react-utils';
810

9-
// import VerifiedBadge from 'assets/images/profile/verified-badge.svg';
10-
// import InfoIcon from 'assets/images/profile/ico-info.svg';
11-
// import Tooltip from 'components/Tooltip';
11+
import VerifiedBadge from 'assets/images/profile/verified-badge.svg';
12+
import InfoIcon from 'assets/images/profile/ico-info.svg';
13+
import Tooltip from 'components/Tooltip';
1214

1315
import './styles.scss';
1416

15-
const ProfileHeader = ({ info }) => {
17+
const verifiedBadgeLookerId = '3322';
18+
19+
const ProfileHeader = ({ getLookerDone, lookerInfo, info }) => {
1620
const [imageUrl, setimageUrl] = useState();
21+
const [isMemberVerified, setIsMemberVerified] = useState(false);
22+
const { handle } = info;
1723

1824
useEffect(() => {
1925
let url = '';
@@ -25,16 +31,29 @@ const ProfileHeader = ({ info }) => {
2531
setimageUrl(url);
2632
}, []);
2733

34+
useEffect(() => {
35+
if (!lookerInfo || lookerInfo.error) {
36+
getLookerDone(verifiedBadgeLookerId);
37+
}
38+
}, []);
39+
40+
useEffect(() => {
41+
if (!lookerInfo || lookerInfo.error) {
42+
return;
43+
}
44+
const { lookerData } = lookerInfo;
45+
const currentUserData = lookerData.find(x => x['user.handle'] === handle);
46+
setIsMemberVerified(currentUserData && currentUserData['member_verification.status'] === 'Verified');
47+
}, [lookerInfo]);
48+
2849
const loadImageError = () => {
2950
setimageUrl(null);
3051
};
3152

32-
// const tooltipContent = (
33-
// <div styleName="tooltip-content">verified member</div>
34-
// );
53+
const tooltipContent = (
54+
<div styleName="tooltip-content">verified member</div>
55+
);
3556

36-
const { handle } = info;
37-
// const isMemberVerified = true;
3857

3958
return (
4059
<div styleName="container">
@@ -55,24 +74,22 @@ const ProfileHeader = ({ info }) => {
5574
{handle}
5675
</div>
5776

58-
{/* { */}
59-
{/* isMemberVerified && ( */}
60-
{/* <div styleName="verified-member"> */}
61-
{/* <VerifiedBadge /> */}
62-
63-
{/* <span>verified member</span> */}
64-
65-
{/* <div styleName="info"> */}
66-
{/* <Tooltip */}
67-
{/* content={tooltipContent} */}
68-
{/* trigger={['hover', 'focus']} */}
69-
{/* > */}
70-
{/* <InfoIcon /> */}
71-
{/* </Tooltip> */}
72-
{/* </div> */}
73-
{/* </div> */}
74-
{/* ) */}
75-
{/* } */}
77+
{isMemberVerified && (
78+
<div styleName="verified-member">
79+
<VerifiedBadge />
80+
81+
<span>verified member</span>
82+
83+
<div styleName="info">
84+
<Tooltip
85+
content={tooltipContent}
86+
trigger={['hover', 'focus']}
87+
>
88+
<InfoIcon />
89+
</Tooltip>
90+
</div>
91+
</div>
92+
)}
7693
</div>
7794

7895
</div>
@@ -85,8 +102,34 @@ ProfileHeader.defaultProps = {
85102
info: {},
86103
};
87104

105+
function mapStateToProps(state) {
106+
const {
107+
looker: {
108+
dataSet,
109+
},
110+
} = state;
111+
return {
112+
lookerInfo: dataSet[verifiedBadgeLookerId],
113+
};
114+
}
115+
116+
function mapDispatchToProps(dispatch) {
117+
return {
118+
getLookerDone: (lookerId) => {
119+
dispatch(actions.looker.getLookerDone(lookerId));
120+
},
121+
};
122+
}
123+
88124
ProfileHeader.propTypes = {
89125
info: PT.shape(),
126+
lookerInfo: PT.shape().isRequired,
127+
getLookerDone: PT.func.isRequired,
90128
};
91129

92-
export default ProfileHeader;
130+
const Container = connect(
131+
mapStateToProps,
132+
mapDispatchToProps,
133+
)(ProfileHeader);
134+
135+
export default Container;

0 commit comments

Comments
 (0)