refactor: destructure some objects in list map iterate

This commit is contained in:
mattyl006 2022-07-27 12:33:16 +02:00
parent 0cd2580957
commit f232ad62b5
2 changed files with 13 additions and 14 deletions

View File

@ -17,7 +17,7 @@ const _renderSubmissions = (pageNr, submissions) => {
if (submissions) { if (submissions) {
return ( return (
<FlexColumn as='tbody' width='100%'> <FlexColumn as='tbody' width='100%'>
{submissions.slice(n, n + ELEMENTS_PER_PAGE).map((submission, index) => { {submissions.slice(n, n + ELEMENTS_PER_PAGE).map(({submitter, when, evaluations, version}, index) => {
return ( return (
<Grid as='tr' key={`leaderboard-row-${index}`} gridTemplateColumns='1fr 3fr 3fr 1fr 1fr' <Grid as='tr' key={`leaderboard-row-${index}`} gridTemplateColumns='1fr 3fr 3fr 1fr 1fr'
gridGap='10px' margin='10px 0 0 0' position='relative' width='100%'> gridGap='10px' margin='10px 0 0 0' position='relative' width='100%'>
@ -25,17 +25,17 @@ const _renderSubmissions = (pageNr, submissions) => {
{index + n + 1} {index + n + 1}
</Body> </Body>
<Body as='td'> <Body as='td'>
{submission.submitter ? submission.submitter : '[anonymous]'} {submitter ? submitter : '[anonymous]'}
</Body> </Body>
<Body as='td'> <Body as='td'>
{submission.when ? `${submission.when.slice(11, 16)} ${submission.when.slice(0, 10)}` {when ? `${when.slice(11, 16)} ${when.slice(0, 10)}`
: 'xxx'} : 'xxx'}
</Body> </Body>
<Body as='td'> <Body as='td'>
{submission.evaluations[0] ? submission.evaluations[0].score : 'xxx'} {evaluations[0] ? evaluations[0].score : 'xxx'}
</Body> </Body>
<Body as='td' textAlign='right' padding='0 2px 0 0'> <Body as='td' textAlign='right' padding='0 2px 0 0'>
{submission.version ? submission.version.length : 1} {version ? version.length : 1}
</Body> </Body>
<Line as='td'/> <Line as='td'/>
</Grid> </Grid>

View File

@ -23,13 +23,12 @@ const _renderChallenges = (pageNr, challenges) => {
if (challenges && challenges !== []) { if (challenges && challenges !== []) {
return ( return (
<ChallengesGrid margin='32px 0' gridGap='32px 0'> <ChallengesGrid margin='32px 0' gridGap='32px 0'>
{challenges.slice(n, n + ELEMENTS_PER_PAGE).map((challenge, index) => { {challenges.slice(n, n + ELEMENTS_PER_PAGE).map(
({title, type, description, mainMetric, bestScore, baseline, prize, deadline, name}, index) => {
return ( return (
<MiniChallenge key={`challenge-${index}`} title={challenge.title} type={challenge.type} <MiniChallenge key={`challenge-${index}`} title={title} type={type}
description={challenge.description} metric={challenge.mainMetric} description={description} metric={mainMetric} bestScore={bestScore}
bestScore={challenge.bestScore} baseline={challenge.baseline} baseline={baseline} prize={prize} deadline={deadline} name={name}/>
prize={challenge.prize} deadline={challenge.deadline}
name={challenge.name}/>
); );
})} })}
</ChallengesGrid> </ChallengesGrid>