Skip to content

fix: fix challenge link for marathon match in member statics page #6303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
import React from 'react';
import PT from 'prop-types';
import './styles.scss';
import _ from 'lodash';

const ChartTooltip = ({
show, left, top, challengeName,
challengeData, rating, ratingColor, href,
challengeData, rating, ratingColor, href, onClick,
}) => (
<a
styleName="chart-tooltip"
Expand All @@ -19,6 +20,10 @@ const ChartTooltip = ({
pointerEvents: href ? 'all' : 'none',
}}
href={href}
onClick={(e) => {
e.preventDefault();
onClick();
}}
>
<div styleName="tooltip-rating" style={{ backgroundColor: ratingColor }}>
{rating}
Expand All @@ -44,6 +49,7 @@ ChartTooltip.defaultProps = {
rating: 0,
ratingColor: '',
href: null,
onClick: _.noop,
};

ChartTooltip.propTypes = {
Expand All @@ -55,6 +61,7 @@ ChartTooltip.propTypes = {
rating: PT.number,
ratingColor: PT.string,
href: PT.string,
onClick: PT.func,
};

export default ChartTooltip;
32 changes: 31 additions & 1 deletion src/shared/components/ProfilePage/Stats/HistoryGraph/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default class HistoryGraph extends React.Component {
this.state = {};
this.mobileWidth = 0;
this.graphRef = React.createRef();
this.onHandleDataPointClicked = this.onHandleDataPointClicked.bind(this);
}

componentDidMount() {
Expand Down Expand Up @@ -58,6 +59,23 @@ export default class HistoryGraph extends React.Component {
return 300;
}

onHandleDataPointClicked() {
const { challengeId, href } = this.state;
fetch(`${config.API.V5}/challenges?legacyId=${challengeId}`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not need call this API to get UUID from challenge, if access challenge with legacyId CA will redirect to UUID url:
example:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmmm, never notice that. will change that.

.then(result => result.json())
.then((dataResponse) => {
if (dataResponse.length > 0) {
const challenge = dataResponse[0];
window.location.href = `${config.URL.CHALLENGES_URL}/${challenge.id}`;
} else {
window.location.href = href;
}
}).catch(() => {
window.location.href = href;
});
}


draw() {
const $scope = this;
const { history: wrapper, track, subTrack } = this.props;
Expand Down Expand Up @@ -247,6 +265,7 @@ export default class HistoryGraph extends React.Component {
show: true,
left: e.pageX,
top: e.pageY,
challengeId: d.challengeId,
challengeName: d.challengeName,
challengeData: moment(d.ratingDate).format('MMM DD, YYYY'),
rating: d.newRating,
Expand All @@ -259,7 +278,18 @@ export default class HistoryGraph extends React.Component {
render() {
return (
<div styleName="history-graph" ref={this.graphRef}>
<ChartTooltip {...this.state} />
<ChartTooltip
{...this.state}
onClick={() => {
const { track } = this.props;
const { href } = this.state;
if (track === 'DATA_SCIENCE') {
this.onHandleDataPointClicked();
} else {
window.location.href = href;
}
}}
/>
</div>
);
}
Expand Down