2
2
* Stats Page. Displays the stats of a TopCoder member.
3
3
*/
4
4
/* eslint-env browser */
5
- import { _ , get } from 'lodash' ;
5
+ import _ from 'lodash' ;
6
6
import React from 'react' ;
7
7
import PT from 'prop-types' ;
8
8
import { Link } from 'react-router-dom' ;
9
9
import { getRatingColor } from 'utils/tc' ;
10
10
import Th from 'assets/images/th.svg' ;
11
+ import DefaultPortrait from 'assets/images/ico-user-default.svg' ;
11
12
import {
12
13
shouldShowGraph , getHistory , getSubTrackStats , getSummary , getDetails ,
13
14
} from 'utils/memberStats' ;
@@ -17,7 +18,6 @@ import styles from './styles.scss';
17
18
import StatsModal from './StatsModal' ;
18
19
import SRMStats from './SRMStats' ;
19
20
import SubTrackChallengeView from './SubTrackChallengeView' ;
20
- import DefaultPortrait from 'assets/images/ico-user-default.svg' ;
21
21
22
22
23
23
class ProfileStats extends React . Component {
@@ -65,11 +65,8 @@ class ProfileStats extends React.Component {
65
65
const subTrackStats = getSubTrackStats ( stats , track , subTrack ) ;
66
66
const subTrackSummary = getSummary ( stats , track , subTrack ) || [ ] ;
67
67
const subTrackDetails = getDetails ( stats , track , subTrack ) || [ ] ;
68
- let srmRating = 0 ;
69
- const ratingObj = subTrackSummary . filter ( ( k ) => k . label === 'rating' ) ;
70
- if ( ratingObj ) {
71
- srmRating = ratingObj [ 0 ] . value ;
72
- }
68
+ const ratingObj = subTrackSummary . filter ( k => k . label === 'rating' ) ;
69
+ const subTrackRating = ratingObj ? ratingObj [ 0 ] . value : 0 ;
73
70
74
71
if ( track === 'DEVELOP' ) {
75
72
const reliability = subTrackSummary . find ( stat => stat . label === 'reliability' ) ;
@@ -135,19 +132,21 @@ Active Challenges
135
132
</ ul >
136
133
< ul styleName = "subtrack-stats" >
137
134
{
138
- subTrackSummary && info &&
135
+ subTrackSummary
136
+ && (
139
137
< li key = { info . handle } >
140
138
< div >
141
139
{ info . photoURL ? < img src = { info . photoURL } onError = { this . loadImageError } styleName = "profile-circle" alt = "Member Portait" /> : < DefaultPortrait styleName = "profile-circle" /> }
142
140
</ div >
143
141
< div
144
142
styleName = "value"
145
143
className = { info . maxRating ? styles . rating : '' }
146
- style = { { color : srmRating ? getRatingColor ( parseInt ( srmRating . replace ( / \D / g, '' ) , 10 ) ) : undefined } }
147
- >
144
+ style = { { color : subTrackRating ? getRatingColor ( parseInt ( subTrackRating . replace ( / \D / g, '' ) , 10 ) ) : undefined } }
145
+ >
148
146
{ info . handle || '-' }
149
147
</ div >
150
148
</ li >
149
+ )
151
150
}
152
151
{
153
152
subTrackSummary . map ( ( { label, value, link } ) => (
0 commit comments