Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit b85ffc8

Browse files
fix search page issue
1 parent d74851b commit b85ffc8

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"eslint-plugin-react": "^4.1.0",
2121
"ignore-styles": "^1.2.0",
2222
"mocha": "^2.4.5",
23-
"mocha-jsdom": "^1.1.0",
23+
"mocha-jsdom": "~1.1.0",
2424
"nock": "^8.0.0",
2525
"react-hot-loader": "^1.3.0",
2626
"redux-logger": "^2.5.0",

src/components/MemberItem/UserStats.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ require('./UserStats.scss')
1111
const UserStats = ({ member, userPlace, searchTermTag }) => {
1212
let userStatsList
1313

14-
const subtracks = getMostRecentSubtracks(member.stats, 5)
14+
const stats = (_.isArray(member.stats) && member.stats.length > 0) ? member.stats[0]:member.stats
15+
const subtracks = getMostRecentSubtracks(stats, 5)
1516

1617
if (subtracks.length) {
1718
userStatsList = <SubtrackList subtracks={subtracks} />

src/components/User/UsernameAndDetails.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const UsernameAndDetails = ({ username, country, numWins, memberSince }) => {
3838
UsernameAndDetails.propTypes = {
3939
username : PropTypes.string.isRequired,
4040
country : PropTypes.string.isRequired,
41-
numWins : PropTypes.number.isRequired,
41+
numWins : PropTypes.number,
4242
memberSince: PropTypes.number.isRequired
4343
}
4444

src/helpers/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export function getMostRecentSubtracks(userStatsByTrack, numResults = Infinity)
144144
const marathonMatchStats = _.get(userStatsByTrack, 'DATA_SCIENCE.MARATHON_MATCH')
145145
const SRMStats = _.get(userStatsByTrack, 'DATA_SCIENCE.SRM')
146146

147-
if (marathonMatchStats.mostRecentEventDate) {
147+
if (marathonMatchStats && marathonMatchStats.mostRecentEventDate) {
148148
subtrackStats.push({
149149
track: 'DATA_SCIENCE',
150150
name: 'MARATHON_MATCH',
@@ -153,7 +153,7 @@ export function getMostRecentSubtracks(userStatsByTrack, numResults = Infinity)
153153
})
154154
}
155155

156-
if (SRMStats.mostRecentEventDate) {
156+
if (SRMStats && SRMStats.mostRecentEventDate) {
157157
subtrackStats.push({
158158
track: 'DATA_SCIENCE',
159159
name: 'SRM',
@@ -167,7 +167,7 @@ export function getMostRecentSubtracks(userStatsByTrack, numResults = Infinity)
167167
const developSubtracks = _.get(userStatsByTrack, 'DEVELOP.subTracks', [])
168168

169169
designSubtracks.forEach((subtrack) => {
170-
if (subtrack.mostRecentEventDate) {
170+
if (subtrack && subtrack.mostRecentEventDate) {
171171
subtrackStats.push({
172172
track: 'DESIGN',
173173
name: subtrack.name,
@@ -178,7 +178,7 @@ export function getMostRecentSubtracks(userStatsByTrack, numResults = Infinity)
178178
})
179179

180180
developSubtracks.forEach((subtrack) => {
181-
if (subtrack.mostRecentEventDate) {
181+
if (subtrack && subtrack.mostRecentEventDate) {
182182
subtrackStats.push({
183183
track: 'DEVELOP',
184184
name: subtrack.name,

0 commit comments

Comments
 (0)