Skip to content
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,11 +5,10 @@
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, onClick,
challengeData, rating, ratingColor, href,
}) => (
<a
styleName="chart-tooltip"
Expand All @@ -20,10 +19,6 @@ const ChartTooltip = ({
pointerEvents: href ? 'all' : 'none',
}}
href={href}
onClick={(e) => {
e.preventDefault();
onClick();
}}
>
<div styleName="tooltip-rating" style={{ backgroundColor: ratingColor }}>
{rating}
Expand All @@ -49,7 +44,6 @@ ChartTooltip.defaultProps = {
rating: 0,
ratingColor: '',
href: null,
onClick: _.noop,
};

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

export default ChartTooltip;
32 changes: 1 addition & 31 deletions src/shared/components/ProfilePage/Stats/HistoryGraph/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ 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 @@ -59,23 +58,6 @@ export default class HistoryGraph extends React.Component {
return 300;
}

onHandleDataPointClicked() {
const { challengeId, href } = this.state;
fetch(`${config.API.V5}/challenges?legacyId=${challengeId}`)
.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 @@ -265,7 +247,6 @@ 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 @@ -278,18 +259,7 @@ export default class HistoryGraph extends React.Component {
render() {
return (
<div styleName="history-graph" ref={this.graphRef}>
<ChartTooltip
{...this.state}
onClick={() => {
const { track } = this.props;
const { href } = this.state;
if (track === 'DATA_SCIENCE') {
this.onHandleDataPointClicked();
} else {
window.location.href = href;
}
}}
/>
<ChartTooltip {...this.state} />
</div>
);
}
Expand Down