Skip to content

Commit 85b8222

Browse files
final fixes on mm dashboard
1 parent fb07dae commit 85b8222

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

src/shared/components/challenge-detail/Header/TabSelector/index.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import PT from 'prop-types';
1010
import { TABS as DETAIL_TABS } from 'actions/page/challenge-details';
1111
import { config } from 'topcoder-react-utils';
1212

13-
import { isMMChallenge } from 'utils/challenge-detail/helper';
1413
import style from './style.scss';
1514

1615
function getSelectorStyle(selectedView, currentView) {
@@ -221,7 +220,7 @@ export default function ChallengeViewSelector(props) {
221220
return '';
222221
})()}
223222
{
224-
(isMMChallenge(challenge)) && (
223+
isMM && (
225224
<a
226225
tabIndex="0"
227226
role="tab"

src/shared/components/challenge-detail/MMDashboard/Graph/index.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@ import HighchartsReact from 'highcharts-react-official';
55
import PT from 'prop-types';
66
import moment from 'moment';
77
import { getRatingColor } from 'utils/tc';
8+
import ReactSVG from 'react-svg';
9+
import { isomorphy } from 'topcoder-react-utils';
810

911
import './styles.scss';
1012
import _ from 'lodash';
1113

14+
15+
let assets;
16+
if (isomorphy.isClientSide()) {
17+
assets = require.context('assets/images', false, /svg/);
18+
}
19+
1220
export default function Graph({ statisticsData, baseline, awardLine }) {
1321
const flatData = [];
1422
const dates = [];
@@ -34,7 +42,7 @@ export default function Graph({ statisticsData, baseline, awardLine }) {
3442
{
3543
data: _.map(flatData, data => ({
3644
x: moment(data.created).valueOf(),
37-
y: data.score,
45+
y: _.max([0, data.score ? (parseFloat(data.score)) : 0]),
3846
name: data.handle,
3947
color: data.ratingColor
4048
|| getRatingColor(data.rating
@@ -104,7 +112,10 @@ export default function Graph({ statisticsData, baseline, awardLine }) {
104112
formatter() {
105113
const str = `
106114
<div style="border-radius:4px;">
107-
<img height="30" width="30" src="${this.point.customData.photoUrl}" style="position: absolute; border-radius: 50%;" />
115+
${this.point.customData.photoUrl
116+
? `<img height="30" width="30" src="${this.point.customData.photoUrl}" style="position: absolute; border-radius: 50%;" />`
117+
: <ReactSVG path={assets('./ico-user-default.svg')} />}
118+
108119
<p style="margin-left: 50px">${this.point.customData.handle}</p>
109120
<br />
110121
<p style="margin-left: 50px;">${this.point.customData.submissionCount} submissions</p>

src/shared/containers/challenge-detail/index.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import Winners from 'components/challenge-detail/Winners';
2323
import MMDashboardGraph from 'components/challenge-detail/MMDashboard/Graph';
2424
import ChallengeDetailsView from 'components/challenge-detail/Specification';
2525
import RecommendedThriveArticles from 'components/challenge-detail/ThriveArticles';
26+
import LoadingIndicator from 'components/LoadingIndicator';
2627
// eslint-disable-next-line max-len
2728
// import RecommendedActiveChallenges from 'components/challenge-detail/RecommendedActiveChallenges';
2829
import Terms from 'containers/Terms';
@@ -215,13 +216,19 @@ class ChallengeDetailPageContainer extends React.Component {
215216
challenge,
216217
// loadingRecommendedChallengesUUID,
217218
history,
219+
selectedTab,
220+
onSelectorClicked,
218221
} = this.props;
219222

220223
if (challenge.isLegacyChallenge && !history.location.pathname.includes(challenge.id)) {
221224
history.location.pathname = `/challenges/${challenge.id}`; // eslint-disable-line no-param-reassign
222225
history.push(history.location.pathname, history.state);
223226
}
224227

228+
if (!checkIsMM(challenge) && selectedTab === DETAIL_TABS.MM_DASHBOARD) {
229+
onSelectorClicked(DETAIL_TABS.DETAILS);
230+
}
231+
225232
// const recommendedTechnology = getRecommendedTags(challenge);
226233
// if (
227234
// challenge
@@ -581,7 +588,9 @@ class ChallengeDetailPageContainer extends React.Component {
581588
&& (!statisticsData || statisticsData.length === 0)
582589
&& (
583590
<div styleName="page">
584-
Dashboard data is not available!
591+
{
592+
!statisticsData ? <LoadingIndicator /> : 'Dashboard data is not available!'
593+
}
585594
</div>
586595
)
587596
}
@@ -591,8 +600,8 @@ class ChallengeDetailPageContainer extends React.Component {
591600
&& (
592601
<MMDashboardGraph
593602
statisticsData={statisticsData}
594-
baseline={_.get(_.find(_.get(challenge, 'metadta', []), meta => meta.name === 'baseline'), 'value', 0)}
595-
awardLine={_.get(_.find(_.get(challenge, 'metadta', []), meta => meta.name === 'awardLine'), 'value', 0)}
603+
baseline={_.get(_.find(_.get(challenge, 'metadata', []), meta => meta.name === 'baseline'), 'value', 0)}
604+
awardLine={_.get(_.find(_.get(challenge, 'metadata', []), meta => meta.name === 'awardLine'), 'value', 0)}
596605
/>
597606
)
598607
}

src/shared/utils/challenge-detail/helper.jsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,6 @@ export function getRecommendedTags(challenge) {
179179
return recommendedTag;
180180
}
181181

182-
/**
183-
* Checks if current challenge is Marathon and Challenge type
184-
* @param {Object} challenge challenge info
185-
*/
186-
export function isMMChallenge(challenge) {
187-
return challenge.track === 'Data Science' && challenge.type === 'Challenge';
188-
}
189-
190182
/**
191183
* Get display recommended challenge
192184
* @param {Object} challenge challenge info

0 commit comments

Comments
 (0)