Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 2 additions & 75 deletions src/shared/components/ProfilePage/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,12 @@
*/
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 './styles.scss';

const verifiedBadgeLookerId = '3322';

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 style]
The setimageUrl function name does not follow camelCase convention. Consider renaming it to setImageUrl for consistency and readability.

const [isMemberVerified, setIsMemberVerified] = useState(false);
const { handle } = info;

useEffect(() => {
Expand All @@ -31,30 +21,10 @@ const ProfileHeader = ({ getLookerDone, lookerInfo, 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">This member is compliant with Topcoder policies<br /> and is a trusted member of the Topcoder community.</div>
);


return (
<div styleName="container">
<div styleName="curve" />
Expand All @@ -73,23 +43,6 @@ const ProfileHeader = ({ getLookerDone, lookerInfo, info }) => {
<div styleName="member-handle">
{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>
)}
</div>

</div>
Expand All @@ -102,34 +55,8 @@ 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,
};

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

export default Container;
export default ProfileHeader;
Loading