Skip to content

Commit 4de4c32

Browse files
committed
fix for issue #4407
1 parent 4c94cb2 commit 4de4c32

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/services/challenges.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ export const ORDER_BY = {
3030
*/
3131
export function normalizeChallenge(challenge, username) {
3232
const phases = challenge.allPhases || challenge.phases || [];
33-
let registrationOpen = phases.filter(d => d.name === 'Registration')[0];
34-
if (registrationOpen && registrationOpen.isOpen) {
35-
registrationOpen = 'Yes';
36-
} else {
37-
registrationOpen = 'No';
33+
const registration = phases.filter(d => d.name === 'Registration')[0];
34+
let registrationOpen = 'No';
35+
let registrationStartDate;
36+
let registrationEndDate;
37+
if (registration) {
38+
registrationStartDate = registration.actualStartDate || registration.scheduledStartDate;
39+
if (registration.isOpen) {
40+
registrationOpen = 'Yes';
41+
}
42+
registrationEndDate = registration.actualEndDate || registration.scheduledEndDate;
3843
}
3944
const groups = {};
4045
if (challenge.groups) {
@@ -56,11 +61,16 @@ export function normalizeChallenge(challenge, username) {
5661
if (submissionEndTimestamp) {
5762
submissionEndTimestamp = submissionEndTimestamp.scheduledEndDate;
5863
}
64+
const prizes = (challenge.prizeSets[0] && challenge.prizeSets[0].prizes) || [];
5965
_.defaults(challenge, {
6066
communities: new Set([COMPETITION_TRACKS[challenge.legacy.track]]),
6167
groups,
6268
registrationOpen,
6369
submissionEndTimestamp,
70+
registrationStartDate,
71+
registrationEndDate,
72+
totalPrize: prizes.reduce((acc, prize) => acc + prize.value, 0),
73+
submissionEndDate: submissionEndTimestamp,
6474
users: username ? { [username]: true } : {},
6575
});
6676
}

0 commit comments

Comments
 (0)