Skip to content

Commit c207fbf

Browse files
Merge pull request #1187 from suppermancool/f2f-30069264-issue-1010
fix issue #1010
2 parents 1b4e108 + 88e3ff4 commit c207fbf

File tree

1 file changed

+97
-74
lines changed
  • src/shared/components/ProfilePage/Header

1 file changed

+97
-74
lines changed

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

Lines changed: 97 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -25,86 +25,109 @@ const TRACK_LABELS = {
2525
DEVELOP: 'DEVELOPER',
2626
};
2727

28-
const ProfileHeader = ({
29-
copilot,
30-
country,
31-
info,
32-
onShowBadges,
33-
showBadgesButton,
34-
wins,
35-
}) => (
36-
<div styleName="container">
37-
<div>
38-
{ info.photoURL ? <img src={info.photoURL} styleName="profile-circle" alt="Member Portait" /> : <DefaultPortrait styleName="profile-circle" /> }
39-
</div>
40-
<div styleName="info">
41-
<h1 style={{ color: getRatingColor(info.maxRating.rating || 0) }} styleName="handle">
42-
{info.handle}
43-
</h1>
44-
<h3 styleName="location-challenges">
45-
{country}
46-
{Boolean(wins) && (
47-
<span>
48-
{' '}
49-
|
50-
{wins}
51-
{' '}
52-
Wins
53-
</span>
28+
class ProfileHeader extends React.Component {
29+
constructor(props) {
30+
super(props);
31+
const {
32+
info,
33+
} = this.props;
34+
const { photoURL } = info;
35+
this.state = {
36+
imageUrl: photoURL,
37+
};
38+
39+
this.loadImageError = this.loadImageError.bind(this);
40+
}
41+
42+
loadImageError() {
43+
this.setState({ imageUrl: null });
44+
}
45+
46+
render() {
47+
const {
48+
copilot,
49+
country,
50+
info,
51+
onShowBadges,
52+
showBadgesButton,
53+
wins,
54+
} = this.props;
55+
const { imageUrl } = this.state;
56+
return (
57+
<div styleName="container">
58+
<div>
59+
{ imageUrl ? <img src={imageUrl} onError={this.loadImageError} styleName="profile-circle" alt="Member Portait" /> : <DefaultPortrait styleName="profile-circle" /> }
60+
</div>
61+
<div styleName="info">
62+
<h1 style={{ color: getRatingColor(info.maxRating.rating || 0) }} styleName="handle">
63+
{info.handle}
64+
</h1>
65+
<h3 styleName="location-challenges">
66+
{country}
67+
{Boolean(wins) && (
68+
<span>
69+
{' '}
70+
|
71+
{wins}
72+
{' '}
73+
Wins
74+
</span>
75+
) }
76+
</h3>
77+
<h3 styleName="tenure">
78+
Member Since
79+
{moment(info.createdAt).format('MMMM, YYYY')}
80+
</h3>
81+
</div>
82+
{
83+
info.tracks && info.tracks.length > 0
84+
&& (
85+
<div styleName="tracks-links">
86+
<div styleName="tracks">
87+
{
88+
[...info.tracks, ...(copilot ? ['COPILOT'] : [])].map(track => (
89+
<a href={`#${track}`} key={track} styleName="track">
90+
{ track === 'COPILOT' && <CopilotIcon styleName="track-icon" /> }
91+
{ track === 'DATA_SCIENCE' && <DataScienceIcon styleName="track-icon" /> }
92+
{ track === 'DESIGN' && <DesignIcon styleName="track-icon" /> }
93+
{ track === 'DEVELOP' && <DevelopIcon styleName="track-icon" /> }
94+
<div styleName="text">
95+
{TRACK_LABELS[track]}
96+
</div>
97+
</a>
98+
))
99+
}
100+
</div>
101+
</div>
102+
)
103+
}
104+
{ info.description && (
105+
<p styleName="description">
106+
{info.description}
107+
</p>
54108
) }
55-
</h3>
56-
<h3 styleName="tenure">
57-
Member Since
58-
{moment(info.createdAt).format('MMMM, YYYY')}
59-
</h3>
60-
</div>
61-
{
62-
info.tracks && info.tracks.length > 0
63-
&& (
64-
<div styleName="tracks-links">
65-
<div styleName="tracks">
109+
<div styleName="links">
66110
{
67-
[...info.tracks, ...(copilot ? ['COPILOT'] : [])].map(track => (
68-
<a href={`#${track}`} key={track} styleName="track">
69-
{ track === 'COPILOT' && <CopilotIcon styleName="track-icon" /> }
70-
{ track === 'DATA_SCIENCE' && <DataScienceIcon styleName="track-icon" /> }
71-
{ track === 'DESIGN' && <DesignIcon styleName="track-icon" /> }
72-
{ track === 'DEVELOP' && <DevelopIcon styleName="track-icon" /> }
73-
<div styleName="text">
74-
{TRACK_LABELS[track]}
75-
</div>
111+
showBadgesButton ? (
112+
<a
113+
onClick={() => onShowBadges()}
114+
onKeyPress={() => onShowBadges()}
115+
role="link"
116+
styleName="link badge-link"
117+
tabIndex="0"
118+
>
119+
Badges
76120
</a>
77-
))
121+
) : null
78122
}
123+
<a href={`${config.URL.FORUMS}/?module=History&userID=${info.userId}`} styleName="link">
124+
Forum Posts
125+
</a>
79126
</div>
80127
</div>
81-
)
82-
}
83-
{ info.description && (
84-
<p styleName="description">
85-
{info.description}
86-
</p>
87-
) }
88-
<div styleName="links">
89-
{
90-
showBadgesButton ? (
91-
<a
92-
onClick={() => onShowBadges()}
93-
onKeyPress={() => onShowBadges()}
94-
role="link"
95-
styleName="link badge-link"
96-
tabIndex="0"
97-
>
98-
Badges
99-
</a>
100-
) : null
101-
}
102-
<a href={`${config.URL.FORUMS}/?module=History&userID=${info.userId}`} styleName="link">
103-
Forum Posts
104-
</a>
105-
</div>
106-
</div>
107-
);
128+
);
129+
}
130+
}
108131

109132
ProfileHeader.defaultProps = {
110133
copilot: false,

0 commit comments

Comments
 (0)