Skip to content

Commit ed87edd

Browse files
committed
feature: profile page show no rating mm entrance
1 parent a2f6055 commit ed87edd

File tree

5 files changed

+57
-6
lines changed

5 files changed

+57
-6
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ exports[`renders a full Profile correctly 1`] = `
3030
<ProfileHeader
3131
copilot={true}
3232
country=""
33+
hasMM={null}
3334
info={
3435
Object {
3536
"competitionCountryCode": "USA",
@@ -198,6 +199,7 @@ exports[`renders a full Profile correctly 1`] = `
198199
<StatsCategory
199200
className=""
200201
handle="testHandle"
202+
hasMM={null}
201203
inModal={false}
202204
stats={
203205
Object {
@@ -644,6 +646,7 @@ exports[`renders an empty Profile correctly 1`] = `
644646
<ProfileHeader
645647
copilot={false}
646648
country=""
649+
hasMM={null}
647650
info={
648651
Object {
649652
"competitionCountryCode": "USA",
@@ -698,6 +701,7 @@ exports[`renders an empty Profile correctly 1`] = `
698701
<StatsCategory
699702
className=""
700703
handle="testHandle"
704+
hasMM={null}
701705
inModal={false}
702706
stats={
703707
Object {

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import React from 'react';
55
import PT from 'prop-types';
6-
import { noop, get } from 'lodash';
6+
import { noop, get, indexOf } from 'lodash';
77
import moment from 'moment';
88
import ReactSVG from 'react-svg';
99

@@ -57,6 +57,7 @@ class ProfileHeader extends React.Component {
5757
info,
5858
onShowBadges,
5959
showBadgesButton,
60+
hasMM,
6061
wins,
6162
} = this.props;
6263
const { imageUrl } = this.state;
@@ -94,7 +95,7 @@ class ProfileHeader extends React.Component {
9495
<div styleName="tracks-links">
9596
<div styleName="tracks">
9697
{
97-
[...info.tracks, ...(copilot ? ['COPILOT'] : [])].map(track => (
98+
[...info.tracks, ...(indexOf(info.track, 'DATA_SCIENCE') === -1 && hasMM ? ['DATA_SCIENCE'] : []), ...(copilot ? ['COPILOT'] : [])].map(track => (
9899
<a href={`#${track}`} key={track} styleName="track">
99100
{ track === 'COPILOT' && <CopilotIcon styleName="track-icon" /> }
100101
{ track === 'DATA_SCIENCE' && <DataScienceIcon styleName="track-icon" /> }
@@ -140,6 +141,7 @@ class ProfileHeader extends React.Component {
140141

141142
ProfileHeader.defaultProps = {
142143
copilot: false,
144+
hasMM: false,
143145
country: '',
144146
info: {},
145147
onShowBadges: noop,
@@ -149,6 +151,7 @@ ProfileHeader.defaultProps = {
149151

150152
ProfileHeader.propTypes = {
151153
copilot: PT.bool,
154+
hasMM: PT.bool,
152155
country: PT.string,
153156
info: PT.shape(),
154157
onShowBadges: PT.func,

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const isHidden = (subtrack) => {
5959
class StatsCategory extends React.Component {
6060
getActiveTracks() {
6161
let { stats } = this.props;
62+
const { hasMM } = this.props;
6263
if (_.isArray(stats)) {
6364
// eslint-disable-next-line prefer-destructuring
6465
stats = stats[0];
@@ -87,7 +88,7 @@ class StatsCategory extends React.Component {
8788
}
8889

8990
subTracks.forEach((subtrack) => {
90-
if (isActiveSubtrack(subtrack) && !isHidden(subtrack)) {
91+
if ((isActiveSubtrack(subtrack) && !isHidden(subtrack)) || (subtrack.name === 'MARATHON MATCH' && hasMM)) {
9192
active.push({ ...subtrack, active: true });
9293
}
9394
});
@@ -106,6 +107,7 @@ class StatsCategory extends React.Component {
106107
render() {
107108
const {
108109
handle,
110+
hasMM,
109111
className,
110112
inModal,
111113
} = this.props;
@@ -148,10 +150,10 @@ class StatsCategory extends React.Component {
148150
style={{ color: getRatingColor(subtrack.rank.rating) }}
149151
styleName="number"
150152
>
151-
{subtrack.rank.rating}
153+
{subtrack.name === 'MARATHON MATCH' && !subtrack.challenges && hasMM ? '' : subtrack.rank.rating}
152154
</div>
153155
<div styleName="tag">
154-
Rating
156+
{subtrack.name === 'MARATHON MATCH' && !subtrack.challenges && hasMM ? 'No Rating' : 'Rating'}
155157
</div>
156158
</div>
157159
)
@@ -198,6 +200,7 @@ class StatsCategory extends React.Component {
198200
StatsCategory.defaultProps = {
199201
className: '',
200202
inModal: false,
203+
hasMM: false,
201204
};
202205

203206
StatsCategory.propTypes = {
@@ -207,6 +210,7 @@ StatsCategory.propTypes = {
207210
PT.shape(),
208211
]).isRequired,
209212
inModal: PT.bool,
213+
hasMM: PT.bool,
210214
className: PT.string,
211215
};
212216

src/shared/components/ProfilePage/index.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class ProfilePage extends React.Component {
124124
copilot,
125125
externalAccounts,
126126
externalLinks,
127+
challenges,
127128
skills: propSkills,
128129
stats,
129130
lookupData,
@@ -167,6 +168,8 @@ class ProfilePage extends React.Component {
167168
}
168169

169170
const activeTracks = this.getActiveTracks();
171+
// no rating MM
172+
const hasMM = challenges && challenges.length;
170173

171174
return (
172175
<div styleName="outer-container">
@@ -192,6 +195,7 @@ class ProfilePage extends React.Component {
192195
>
193196
<div styleName="sticky-container">
194197
<Header
198+
hasMM={hasMM}
195199
copilot={copilot}
196200
country={country}
197201
info={info}
@@ -272,7 +276,11 @@ class ProfilePage extends React.Component {
272276
{
273277
!_.isEmpty(stats) && (
274278
<div id="profile-activity">
275-
<StatsCategory handle={info.handle} stats={stats} />
279+
<StatsCategory
280+
handle={info.handle}
281+
stats={stats}
282+
hasMM={hasMM}
283+
/>
276284
</div>
277285
)
278286
}
@@ -310,6 +318,7 @@ ProfilePage.defaultProps = {
310318
externalAccounts: null,
311319
externalLinks: null,
312320
achievements: [],
321+
challenges: null,
313322
skills: null,
314323
stats: null,
315324
};
@@ -318,6 +327,7 @@ ProfilePage.propTypes = {
318327
achievements: PT.arrayOf(PT.shape()),
319328
copilot: PT.bool.isRequired,
320329
externalAccounts: PT.shape(),
330+
challenges: PT.arrayOf(PT.shape()),
321331
externalLinks: PT.arrayOf(PT.shape()),
322332
info: PT.shape().isRequired,
323333
skills: PT.shape(),

src/shared/containers/Profile.jsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,31 @@ import PT from 'prop-types';
77
import { connect } from 'react-redux';
88
import { config } from 'topcoder-react-utils';
99
import { actions } from 'topcoder-react-lib';
10+
import shortId from 'shortid';
1011
import MetaTags from 'components/MetaTags';
1112
import Error404 from 'components/Error404';
1213
import LoadingIndicator from 'components/LoadingIndicator';
1314
import ProfilePage from 'components/ProfilePage';
1415
import { loadPublicStatsOnly } from 'utils/memberStats';
1516

17+
// how many challenges to query per batch
18+
const CHALLENGE_PER_PAGE = 36;
19+
1620
class ProfileContainer extends React.Component {
1721
componentDidMount() {
1822
const {
1923
handleParam,
2024
loadProfile,
25+
loadMarathon,
2126
meta,
2227
auth,
28+
info,
2329
} = this.props;
2430
loadProfile(handleParam, _.get(meta, 'groupIds', []), auth.tokenV3, loadPublicStatsOnly(meta));
2531

32+
if (info) {
33+
loadMarathon(handleParam, auth.tokenV3, info.userId);
34+
}
2635
// Redirect to the communities own profile page if
2736
// - the member whose profile is being viewed is part of one of the configured communities
2837
// - the user is not a topcoder user (has an email with @topcoder.com)
@@ -53,6 +62,7 @@ class ProfileContainer extends React.Component {
5362
handleParam,
5463
profileForHandle,
5564
loadProfile,
65+
loadMarathon,
5666
loadMemberGroups,
5767
meta,
5868
auth,
@@ -69,6 +79,9 @@ class ProfileContainer extends React.Component {
6979
loadProfile(handleParam, _.get(meta, 'groupIds', []), auth.tokenV3, loadPublicStatsOnly(meta));
7080
}
7181

82+
if (info && info.userId && info !== prevInfo) {
83+
loadMarathon(handleParam, auth.tokenV3, info.userId);
84+
}
7285
if (auth.tokenV3 && auth.user && auth.user.handle !== handleParam
7386
&& info != null && info.userId != null
7487
&& (prevInfo == null || info.userId !== prevInfo.userId)) {
@@ -158,6 +171,7 @@ ProfileContainer.propTypes = {
158171
handleParam: PT.string.isRequired,
159172
info: PT.shape(),
160173
loadingError: PT.bool.isRequired,
174+
loadMarathon: PT.bool.isRequired,
161175
loadProfile: PT.func.isRequired,
162176
loadMemberGroups: PT.func.isRequired,
163177
profileForHandle: PT.string,
@@ -170,6 +184,8 @@ ProfileContainer.propTypes = {
170184
};
171185

172186
const mapStateToProps = (state, ownProps) => ({
187+
challenges: state.members[ownProps.match.params.handle]
188+
? state.members[ownProps.match.params.handle].subtrackChallenges : null,
173189
achievements: state.profile.achievements,
174190
copilot: state.profile.copilot,
175191
country: state.profile.country,
@@ -192,6 +208,7 @@ const mapStateToProps = (state, ownProps) => ({
192208
function mapDispatchToProps(dispatch) {
193209
const a = actions.profile;
194210
const lookupActions = actions.lookup;
211+
const memberActions = actions.members;
195212
return {
196213
loadMemberGroups: (userId, tokenV3) => {
197214
dispatch(actions.groups.getMemberGroups(userId, tokenV3));
@@ -214,6 +231,19 @@ function mapDispatchToProps(dispatch) {
214231
dispatch(a.getStatsDone(handle, showPublicStats ? undefined : groupIds, tokenV3));
215232
dispatch(lookupActions.getCountriesDone());
216233
},
234+
loadMarathon: (handle, tokenV3, memberId) => {
235+
const uuid = shortId();
236+
dispatch(memberActions.getUserMarathonInit(handle, uuid));
237+
dispatch(memberActions.getUserMarathonDone(
238+
uuid,
239+
handle,
240+
memberId,
241+
tokenV3,
242+
1,
243+
CHALLENGE_PER_PAGE,
244+
true,
245+
));
246+
},
217247
};
218248
}
219249

0 commit comments

Comments
 (0)