From f596ebe9f0e95914f2f42022d5cd47495caf47fb Mon Sep 17 00:00:00 2001 From: Kariamos Date: Mon, 29 Jan 2024 15:01:35 +0100 Subject: [PATCH] refactor: modified variables --- src/pages/ExperiencePoints/index.tsx | 54 +++++++++++++++------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/src/pages/ExperiencePoints/index.tsx b/src/pages/ExperiencePoints/index.tsx index a0d64f46..c883e806 100644 --- a/src/pages/ExperiencePoints/index.tsx +++ b/src/pages/ExperiencePoints/index.tsx @@ -57,29 +57,33 @@ export default function ExperiencePoints() { dispatch(updateExperiencePointsPagination(newStart)); }; - const rows = (results ?? []).map((res) => { - return { - key: res.id, - amount: { - title: `${res.amount > 0 ? `+${res.amount}` : res.amount}pts`, - content: - res.amount === 0 ? ( - {res.amount}pts - ) : res.amount > 0 ? ( - +{res.amount}pts - ) : ( - {res.amount}pts - ), - }, - date: dateFormatter(res.date), - activity: mapActivityName(res.activity.id, t), - campaign: - res.campaign.title && res.campaign.id > 0 - ? `CP${res.campaign.id}` - : `-`, - note: res.note?.replace(/\\(.)/gm, "$1"), - }; - }); + const rows = error + ? [] + : (results ?? []).map((res) => { + return { + key: res.id, + amount: { + title: `${res.amount > 0 ? `+${res.amount}` : res.amount}pts`, + content: + res.amount === 0 ? ( + {res.amount}pts + ) : res.amount > 0 ? ( + +{res.amount}pts + ) : ( + {res.amount}pts + ), + }, + date: dateFormatter(res.date), + activity: mapActivityName(res.activity.id, t), + campaign: + res.campaign.title && res.campaign.id > 0 + ? `CP${res.campaign.id}` + : `-`, + note: res.note?.replace(/\\(.)/gm, "$1"), + }; + }); + + const totalResults = error ? 1 : total ?? 0; useEffect(() => { if ( @@ -104,10 +108,10 @@ export default function ExperiencePoints() {