Skip to content

Commit 022d8a6

Browse files
committed
Add email to registrants view and clean up submission download functionality for Download challenges
#1537 #1535
1 parent 75c7bdd commit 022d8a6

File tree

6 files changed

+367
-244
lines changed

6 files changed

+367
-244
lines changed

src/actions/challenges.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
createResource as createResourceAPI,
2323
deleteResource as deleteResourceAPI
2424
} from '../services/challenges'
25+
import { searchProfilesByUserIds } from '../services/user'
2526
import {
2627
LOAD_CHALLENGE_DETAILS,
2728
LOAD_CHALLENGE_METADATA_SUCCESS,
@@ -46,8 +47,10 @@ import {
4647
DELETE_CHALLENGE_PENDING,
4748
DELETE_CHALLENGE_SUCCESS,
4849
DELETE_CHALLENGE_FAILURE,
49-
LOAD_CHALLENGE_RESOURCES,
50-
CHALLENGE_STATUS
50+
CHALLENGE_STATUS,
51+
LOAD_CHALLENGE_RESOURCES_SUCCESS,
52+
LOAD_CHALLENGE_RESOURCES_PENDING,
53+
LOAD_CHALLENGE_RESOURCES_FAILURE
5154
} from '../config/constants'
5255
import { loadProject } from './projects'
5356
import { removeChallengeFromPhaseProduct, saveChallengeAsPhaseProduct } from '../services/projects'
@@ -595,12 +598,29 @@ export function loadChallengeTerms () {
595598
}
596599

597600
export function loadResources (challengeId) {
598-
return (dispatch, getState) => {
601+
return async (dispatch, getState) => {
599602
if (challengeId) {
600-
return dispatch({
601-
type: LOAD_CHALLENGE_RESOURCES,
602-
payload: fetchResources(challengeId)
603-
})
603+
let challengeResources = []
604+
try {
605+
dispatch({
606+
type: LOAD_CHALLENGE_RESOURCES_PENDING
607+
})
608+
challengeResources = await fetchResources(challengeId)
609+
const memberIds = challengeResources.map(resource => resource.memberId)
610+
const memberInfos = await searchProfilesByUserIds(memberIds)
611+
_.forEach(challengeResources, (cr) => {
612+
const memerInfo = _.find(memberInfos, { userId: parseInt(cr.memberId) })
613+
cr.email = memerInfo ? memerInfo.email : ''
614+
})
615+
dispatch({
616+
type: LOAD_CHALLENGE_RESOURCES_SUCCESS,
617+
payload: challengeResources
618+
})
619+
} catch (error) {
620+
dispatch({
621+
type: LOAD_CHALLENGE_RESOURCES_FAILURE
622+
})
623+
}
604624
}
605625
}
606626
}

src/components/ChallengeEditor/Registrants/Registrants.module.scss

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ $member-red: #ea1900;
3636
color: $tc-gray-50;
3737
display: flex;
3838
border-bottom: 1px solid $tc-gray-10;
39+
gap: 20px;
3940

4041
@include xs-to-sm {
4142
display: none;
@@ -52,6 +53,7 @@ $member-red: #ea1900;
5253

5354
.row {
5455
display: flex;
56+
gap: 20px;
5557
line-height: 50px;
5658
color: $tc-gray-70;
5759
font-size: 15px;
@@ -85,7 +87,8 @@ $member-red: #ea1900;
8587
.col-3,
8688
.col-4,
8789
.col-5,
88-
.col-6 {
90+
.col-6,
91+
.col-7 {
8992
display: flex;
9093
align-items: center;
9194
border: none;
@@ -155,7 +158,8 @@ $member-red: #ea1900;
155158
}
156159

157160
.col-2 {
158-
width: 150px;
161+
width: 100px;
162+
flex-shrink: 0;
159163
margin-left: 20px;
160164

161165
@include xs-to-sm {
@@ -167,7 +171,8 @@ $member-red: #ea1900;
167171
}
168172

169173
.col-3 {
170-
width: 298px;
174+
width: 100px;
175+
flex-shrink: 0;
171176

172177
@include xs-to-sm {
173178
font-size: 15px;
@@ -185,8 +190,28 @@ $member-red: #ea1900;
185190
}
186191
}
187192

193+
.col-7 {
194+
width: 200px;
195+
margin-left: 20px;
196+
flex-shrink: 0;
197+
198+
span {
199+
max-width: 100%;
200+
text-overflow: ellipsis;
201+
overflow: hidden;
202+
}
203+
204+
@include xs-to-sm {
205+
padding-left: 0;
206+
margin-bottom: 10px;
207+
line-height: 20px;
208+
width: auto;
209+
}
210+
}
211+
188212
.col-4 {
189-
width: 317px;
213+
width: 200px;
214+
flex-shrink: 0;
190215

191216
@include xs-to-sm {
192217
margin-bottom: 15px;
@@ -211,7 +236,8 @@ $member-red: #ea1900;
211236
.col-6 {
212237
display: flex;
213238
align-items: center;
214-
width: 351px;
239+
width: 200px;
240+
flex-shrink: 0;
215241

216242
@include xs-to-sm {
217243
line-height: 20px;

src/components/ChallengeEditor/Registrants/index.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ export default class Registrants extends React.Component {
229229
valueIsString = true
230230
break
231231
}
232+
case 'Email': {
233+
valueA = `${a.email}`.toLowerCase()
234+
valueB = `${b.email}`.toLowerCase()
235+
valueIsString = true
236+
break
237+
}
232238
case 'Registration Date': {
233239
valueA = new Date(a.created)
234240
valueB = new Date(b.created)
@@ -339,6 +345,27 @@ export default class Registrants extends React.Component {
339345
<ReactSVG path={assets(`${ArrowDown}`)} />
340346
</div>
341347
</button>
348+
<button
349+
onClick={() => {
350+
this.onSortChange({
351+
field: 'Email',
352+
sort: field === 'Email' ? revertSort : 'desc'
353+
})
354+
}}
355+
type='button'
356+
className={cn(styles['col-7'], styles['table-header'])}
357+
>
358+
<span role='columnheader'>Email</span>
359+
<div
360+
className={cn(styles['col-arrow'], {
361+
[styles['col-arrow-sort-asc']]:
362+
field === 'Email' && sort === 'asc',
363+
[styles['col-arrow-is-sorting']]: field === 'Email'
364+
})}
365+
>
366+
<ReactSVG path={assets(`${ArrowDown}`)} />
367+
</div>
368+
</button>
342369
<button
343370
className={cn(styles['col-4'], styles['table-header'])}
344371
onClick={() => {
@@ -453,6 +480,12 @@ export default class Registrants extends React.Component {
453480
</a>
454481
</span>
455482
</div>
483+
<div className={styles['col-7']}>
484+
<div className={cn(styles['sm-only'], styles['title'])}>
485+
Email
486+
</div>
487+
<span role='cell'>{r.email}</span>
488+
</div>
456489
<div className={styles['col-4']}>
457490
<div className={cn(styles['sm-only'], styles['title'])}>
458491
Registration Date

src/components/ChallengeEditor/Submissions/Submissions.module.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,12 @@ $base-unit: 5px;
332332
flex-shrink: 0;
333333
}
334334

335+
.col-9 {
336+
display: flex;
337+
width: 200px;
338+
flex-shrink: 0;
339+
}
340+
335341
.col-4 {
336342
display: flex;
337343
width: 150px;
@@ -378,7 +384,7 @@ $base-unit: 5px;
378384
.submissionsContainer {
379385
display: flex;
380386
flex-direction: column;
381-
max-width: 1100px;
387+
max-width: 1300px;
382388
width: 100%;
383389
overflow: auto;
384390
}

0 commit comments

Comments
 (0)