From f232ad62b537d4c12649c4de48eedfa19f3d841d Mon Sep 17 00:00:00 2001 From: mattyl006 Date: Wed, 27 Jul 2022 12:33:16 +0200 Subject: [PATCH] refactor: destructure some objects in list map iterate --- .../elements/Table/_renderSubmissions.js | 10 +++++----- src/pages/Challanges/_renderChallenges.js | 17 ++++++++--------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/components/elements/Table/_renderSubmissions.js b/src/components/elements/Table/_renderSubmissions.js index adfb0a1..62a0fcb 100644 --- a/src/components/elements/Table/_renderSubmissions.js +++ b/src/components/elements/Table/_renderSubmissions.js @@ -17,7 +17,7 @@ const _renderSubmissions = (pageNr, submissions) => { if (submissions) { return ( - {submissions.slice(n, n + ELEMENTS_PER_PAGE).map((submission, index) => { + {submissions.slice(n, n + ELEMENTS_PER_PAGE).map(({submitter, when, evaluations, version}, index) => { return ( @@ -25,17 +25,17 @@ const _renderSubmissions = (pageNr, submissions) => { {index + n + 1} - {submission.submitter ? submission.submitter : '[anonymous]'} + {submitter ? submitter : '[anonymous]'} - {submission.when ? `${submission.when.slice(11, 16)} ${submission.when.slice(0, 10)}` + {when ? `${when.slice(11, 16)} ${when.slice(0, 10)}` : 'xxx'} - {submission.evaluations[0] ? submission.evaluations[0].score : 'xxx'} + {evaluations[0] ? evaluations[0].score : 'xxx'} - {submission.version ? submission.version.length : 1} + {version ? version.length : 1} diff --git a/src/pages/Challanges/_renderChallenges.js b/src/pages/Challanges/_renderChallenges.js index 976fc59..b8bc28d 100644 --- a/src/pages/Challanges/_renderChallenges.js +++ b/src/pages/Challanges/_renderChallenges.js @@ -23,15 +23,14 @@ const _renderChallenges = (pageNr, challenges) => { if (challenges && challenges !== []) { return ( - {challenges.slice(n, n + ELEMENTS_PER_PAGE).map((challenge, index) => { - return ( - - ); - })} + {challenges.slice(n, n + ELEMENTS_PER_PAGE).map( + ({title, type, description, mainMetric, bestScore, baseline, prize, deadline, name}, index) => { + return ( + + ); + })} ) }