Skip to content

Commit

Permalink
Merge pull request #6563 from topcoder-platform/develop
Browse files Browse the repository at this point in the history
Release v1.17.7
  • Loading branch information
luizrrodrigues authored Jun 24, 2022
2 parents d7d5d2b + 13829af commit 0994dc0
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`renders a full Profile correctly 1`] = `
className="src-shared-components-ProfilePage-___styles__outer-container___3in3p"
>
<div>
<ProfileHeader
<Connect(ProfileHeader)
info={
Object {
"competitionCountryCode": "USA",
Expand Down Expand Up @@ -717,7 +717,7 @@ exports[`renders an empty Profile correctly 1`] = `
className="src-shared-components-ProfilePage-___styles__outer-container___3in3p"
>
<div>
<ProfileHeader
<Connect(ProfileHeader)
info={
Object {
"competitionCountryCode": "USA",
Expand Down
99 changes: 71 additions & 28 deletions src/shared/components/ProfilePage/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@
*/
import React, { useEffect, useState } from 'react';
import PT from 'prop-types';
import { connect } from 'react-redux';

import { actions } from 'topcoder-react-lib';
import { isomorphy } from 'topcoder-react-utils';

// import VerifiedBadge from 'assets/images/profile/verified-badge.svg';
// import InfoIcon from 'assets/images/profile/ico-info.svg';
// import Tooltip from 'components/Tooltip';
import VerifiedBadge from 'assets/images/profile/verified-badge.svg';
import InfoIcon from 'assets/images/profile/ico-info.svg';
import Tooltip from 'components/Tooltip';

import './styles.scss';

const ProfileHeader = ({ info }) => {
const verifiedBadgeLookerId = '3322';

const ProfileHeader = ({ getLookerDone, lookerInfo, info }) => {
const [imageUrl, setimageUrl] = useState();
const [isMemberVerified, setIsMemberVerified] = useState(false);
const { handle } = info;

useEffect(() => {
let url = '';
Expand All @@ -25,16 +31,29 @@ const ProfileHeader = ({ info }) => {
setimageUrl(url);
}, []);

useEffect(() => {
if (!lookerInfo || lookerInfo.error) {
getLookerDone(verifiedBadgeLookerId);
}
}, []);

useEffect(() => {
if (!lookerInfo || lookerInfo.error) {
return;
}
const { lookerData } = lookerInfo;
const currentUserData = lookerData.find(x => x['user.handle'] === handle);
setIsMemberVerified(currentUserData && currentUserData['member_verification.status'] === 'Verified');
}, [lookerInfo]);

const loadImageError = () => {
setimageUrl(null);
};

// const tooltipContent = (
// <div styleName="tooltip-content">verified member</div>
// );
const tooltipContent = (
<div styleName="tooltip-content">verified member</div>
);

const { handle } = info;
// const isMemberVerified = true;

return (
<div styleName="container">
Expand All @@ -55,24 +74,22 @@ const ProfileHeader = ({ info }) => {
{handle}
</div>

{/* { */}
{/* isMemberVerified && ( */}
{/* <div styleName="verified-member"> */}
{/* <VerifiedBadge /> */}

{/* <span>verified member</span> */}

{/* <div styleName="info"> */}
{/* <Tooltip */}
{/* content={tooltipContent} */}
{/* trigger={['hover', 'focus']} */}
{/* > */}
{/* <InfoIcon /> */}
{/* </Tooltip> */}
{/* </div> */}
{/* </div> */}
{/* ) */}
{/* } */}
{isMemberVerified && (
<div styleName="verified-member">
<VerifiedBadge />

<span>verified member</span>

<div styleName="info">
<Tooltip
content={tooltipContent}
trigger={['hover', 'focus']}
>
<InfoIcon />
</Tooltip>
</div>
</div>
)}
</div>

</div>
Expand All @@ -85,8 +102,34 @@ ProfileHeader.defaultProps = {
info: {},
};

function mapStateToProps(state) {
const {
looker: {
dataSet,
},
} = state;
return {
lookerInfo: dataSet[verifiedBadgeLookerId],
};
}

function mapDispatchToProps(dispatch) {
return {
getLookerDone: (lookerId) => {
dispatch(actions.looker.getLookerDone(lookerId));
},
};
}

ProfileHeader.propTypes = {
info: PT.shape(),
lookerInfo: PT.shape().isRequired,
getLookerDone: PT.func.isRequired,
};

export default ProfileHeader;
const Container = connect(
mapStateToProps,
mapDispatchToProps,
)(ProfileHeader);

export default Container;

0 comments on commit 0994dc0

Please sign in to comment.