Skip to content

Commit b1201cf

Browse files
authored
Merge pull request #4571 from nursoltan-s/issue-4546
Issue 4546
2 parents 12b4b31 + 8894c70 commit b1201cf

File tree

2 files changed

+43
-17
lines changed

2 files changed

+43
-17
lines changed

src/shared/components/challenge-detail/Registrants/index.jsx

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@ import PT from 'prop-types';
88
import moment from 'moment';
99
import _ from 'lodash';
1010
import cn from 'classnames';
11+
import { getRatingLevel } from 'utils/tc';
1112

1213
import sortList from 'utils/challenge-detail/sort';
1314
import CheckMark from '../icons/check-mark.svg';
1415
import ArrowDown from '../../../../assets/images/arrow-down.svg';
1516
import './style.scss';
1617

18+
const BUG_HUNT = 'Bug Hunt';
19+
const F2F = 'First2Finish';
20+
1721
function formatDate(date) {
1822
if (!date) return '-';
19-
return moment(date).format('MMM DD, YYYY HH:mm');
23+
return moment(date).local().format('MMM DD, YYYY HH:mm');
2024
}
2125

2226
function getDate(arr, handle) {
@@ -194,8 +198,8 @@ export default class Registrants extends React.Component {
194198
break;
195199
}
196200
case 'Registration Date': {
197-
valueA = new Date(a.registrationDate);
198-
valueB = new Date(b.registrationDate);
201+
valueA = new Date(a.created);
202+
valueB = new Date(b.created);
199203
break;
200204
}
201205
case 'Round 1 Submitted Date': {
@@ -241,14 +245,20 @@ export default class Registrants extends React.Component {
241245
const {
242246
prizeSets,
243247
legacy,
248+
type,
244249
} = challenge;
250+
245251
const { track } = legacy;
252+
246253
const { sortedRegistrants } = this.state;
247254
const { field, sort } = this.getRegistrantsSortParam();
248255
const revertSort = (sort === 'desc') ? 'asc' : 'desc';
249256
const isDesign = track.toLowerCase() === 'design';
250257
const isF2F = track.indexOf('FIRST_2_FINISH') > -1;
251-
const isBugHunt = track.indexOf('BUG_HUNT') > -1;
258+
259+
const isBugHunt = track.indexOf('BUG_HUNT') > -1
260+
|| type === BUG_HUNT
261+
|| type === F2F;
252262
const placementPrizes = _.find(prizeSets, { type: 'placement' });
253263
const { prizes } = placementPrizes || [];
254264

@@ -382,17 +392,11 @@ export default class Registrants extends React.Component {
382392
{
383393
sortedRegistrants.map((r) => {
384394
const placement = getPlace(results, r.memberHandle, places);
385-
const colorStyle = JSON.parse(r.colorStyle.replace(/(\w+):\s*([^;]*)/g, '{"$1": "$2"}'));
386395
let checkpoint = this.getCheckPoint(r);
387396
if (checkpoint) {
388397
checkpoint = formatDate(checkpoint);
389398
}
390-
let final = this.getFinal(r);
391-
if (final) {
392-
final = formatDate(final);
393-
} else {
394-
final = '-';
395-
}
399+
const final = this.getFinal(r);
396400

397401
return (
398402
<div styleName="row" key={r.memberHandle} role="row">
@@ -403,8 +407,11 @@ export default class Registrants extends React.Component {
403407
Rating
404408
</div>
405409
<div>
406-
<span style={colorStyle} role="cell">
407-
{ !_.isNil(r.rating) ? r.rating : '-'}
410+
<span
411+
styleName={`level-${getRatingLevel(_.get(r, 'rating', 0))}`}
412+
role="cell"
413+
>
414+
{ (!_.isNil(r.rating) && r.rating !== 0) ? r.rating : '-'}
408415
</span>
409416
</div>
410417
</div>
@@ -414,7 +421,7 @@ export default class Registrants extends React.Component {
414421
<span role="cell">
415422
<a
416423
href={`${window.origin}/members/${r.memberHandle}`}
417-
style={colorStyle}
424+
styleName={`level-${getRatingLevel(_.get(r, 'rating', 0))}`}
418425
target={`${_.includes(window.origin, 'www') ? '_self' : '_blank'}`}
419426
>
420427
{r.memberHandle}
@@ -453,7 +460,7 @@ export default class Registrants extends React.Component {
453460
</div>
454461
<div>
455462
<span role="cell">
456-
{final}
463+
{formatDate(final)}
457464
</span>
458465
{placement > 0 && (
459466
<span role="cell" styleName={`placement ${placement < 4 ? `placement-${placement}` : ''}`}>
@@ -496,6 +503,7 @@ Registrants.propTypes = {
496503
registrants: PT.arrayOf(PT.shape()).isRequired,
497504
round1Introduction: PT.string,
498505
round2Introduction: PT.string,
506+
type: PT.string,
499507
}).isRequired,
500508
results: PT.arrayOf(PT.shape()),
501509
checkpointResults: PT.shape(),

src/shared/components/challenge-detail/Registrants/style.scss

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,6 @@
163163
a,
164164
a:hover,
165165
a:visited {
166-
color: $tc-dark-blue-110;
167-
168166
&:hover {
169167
text-decoration: underline;
170168
}
@@ -281,3 +279,23 @@
281279
margin: 10px 10px 0 10px;
282280
padding-top: 5px;
283281
}
282+
283+
.level-1 {
284+
color: $tc-level-1 !important;
285+
}
286+
287+
.level-2 {
288+
color: $tc-level-2 !important;
289+
}
290+
291+
.level-3 {
292+
color: $tc-level-3 !important;
293+
}
294+
295+
.level-4 {
296+
color: $tc-level-4 !important;
297+
}
298+
299+
.level-5 {
300+
color: $tc-level-5 !important;
301+
}

0 commit comments

Comments
 (0)