Skip to content

Commit 141121b

Browse files
Merge pull request #6324 from topcoder-platform/revert-6322-revert-6303-stat_marathon_match_link
Revert "Revert "fix: fix challenge link for marathon match in member statics page""
2 parents 967e5fc + d0be12a commit 141121b

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

src/shared/components/ProfilePage/Stats/ChartTooltip/index.jsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
import React from 'react';
66
import PT from 'prop-types';
77
import './styles.scss';
8+
import _ from 'lodash';
89

910
const ChartTooltip = ({
1011
show, left, top, challengeName,
11-
challengeData, rating, ratingColor, href,
12+
challengeData, rating, ratingColor, href, onClick,
1213
}) => (
1314
<a
1415
styleName="chart-tooltip"
@@ -19,6 +20,10 @@ const ChartTooltip = ({
1920
pointerEvents: href ? 'all' : 'none',
2021
}}
2122
href={href}
23+
onClick={(e) => {
24+
e.preventDefault();
25+
onClick();
26+
}}
2227
>
2328
<div styleName="tooltip-rating" style={{ backgroundColor: ratingColor }}>
2429
{rating}
@@ -44,6 +49,7 @@ ChartTooltip.defaultProps = {
4449
rating: 0,
4550
ratingColor: '',
4651
href: null,
52+
onClick: _.noop,
4753
};
4854

4955
ChartTooltip.propTypes = {
@@ -55,6 +61,7 @@ ChartTooltip.propTypes = {
5561
rating: PT.number,
5662
ratingColor: PT.string,
5763
href: PT.string,
64+
onClick: PT.func,
5865
};
5966

6067
export default ChartTooltip;

src/shared/components/ProfilePage/Stats/HistoryGraph/index.jsx

+31-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default class HistoryGraph extends React.Component {
1515
this.state = {};
1616
this.mobileWidth = 0;
1717
this.graphRef = React.createRef();
18+
this.onHandleDataPointClicked = this.onHandleDataPointClicked.bind(this);
1819
}
1920

2021
componentDidMount() {
@@ -58,6 +59,23 @@ export default class HistoryGraph extends React.Component {
5859
return 300;
5960
}
6061

62+
onHandleDataPointClicked() {
63+
const { challengeId, href } = this.state;
64+
fetch(`${config.API.V5}/challenges?legacyId=${challengeId}`)
65+
.then(result => result.json())
66+
.then((dataResponse) => {
67+
if (dataResponse.length > 0) {
68+
const challenge = dataResponse[0];
69+
window.location.href = `${config.URL.CHALLENGES_URL}/${challenge.id}`;
70+
} else {
71+
window.location.href = href;
72+
}
73+
}).catch(() => {
74+
window.location.href = href;
75+
});
76+
}
77+
78+
6179
draw() {
6280
const $scope = this;
6381
const { history: wrapper, track, subTrack } = this.props;
@@ -247,6 +265,7 @@ export default class HistoryGraph extends React.Component {
247265
show: true,
248266
left: e.pageX,
249267
top: e.pageY,
268+
challengeId: d.challengeId,
250269
challengeName: d.challengeName,
251270
challengeData: moment(d.ratingDate).format('MMM DD, YYYY'),
252271
rating: d.newRating,
@@ -259,7 +278,18 @@ export default class HistoryGraph extends React.Component {
259278
render() {
260279
return (
261280
<div styleName="history-graph" ref={this.graphRef}>
262-
<ChartTooltip {...this.state} />
281+
<ChartTooltip
282+
{...this.state}
283+
onClick={() => {
284+
const { track } = this.props;
285+
const { href } = this.state;
286+
if (track === 'DATA_SCIENCE') {
287+
this.onHandleDataPointClicked();
288+
} else {
289+
window.location.href = href;
290+
}
291+
}}
292+
/>
263293
</div>
264294
);
265295
}

0 commit comments

Comments
 (0)