From c5d45ac7c4bcef4a86b8fef036d9f7532fd25bae Mon Sep 17 00:00:00 2001 From: Mateusz Date: Thu, 15 Dec 2022 10:11:32 +0100 Subject: [PATCH] fix MyEntries when metric tests is none --- src/api/getMyEntries.js | 18 ++++++++++-------- src/components/specific_challenge/Table.js | 10 +++++++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/api/getMyEntries.js b/src/api/getMyEntries.js index 2d2af05..ab9a51f 100644 --- a/src/api/getMyEntries.js +++ b/src/api/getMyEntries.js @@ -23,14 +23,16 @@ const getMyEntries = (challengeName, setDataOriginalState, setDataStateForSearch }; } for (let test of tests) { - if (!Object.hasOwn(item.evaluations, `${test.metric}.${test.name}`)) { - item = { - ...item, - evaluations: { - ...item.evaluations, - [`${test.metric}.${test.name}`]: '-1' - } - }; + if (item.evaluations) { + if (!Object.hasOwn(item.evaluations, `${test.metric}.${test.name}`)) { + item = { + ...item, + evaluations: { + ...item.evaluations, + [`${test.metric}.${test.name}`]: '-1' + } + }; + } } } item = { diff --git a/src/components/specific_challenge/Table.js b/src/components/specific_challenge/Table.js index fc919fc..3ec5a84 100644 --- a/src/components/specific_challenge/Table.js +++ b/src/components/specific_challenge/Table.js @@ -121,10 +121,14 @@ const Table = (props) => { else { let newElem = []; for (let metric of props.possibleMetrics) { - if (elem[props.iterableColumnElement.name][metric] === '-1') + if (Object.hasOwn(elem, props.iterableColumnElement.name)) { + if (elem[props.iterableColumnElement.name][metric] === '-1') + newElem.push('N/A'); + else + newElem.push(elem[props.iterableColumnElement.name][metric]); + } else { newElem.push('N/A'); - else - newElem.push(elem[props.iterableColumnElement.name][metric]); + } } elem = newElem; }