From f16c2d4aefb324901b32b6e9baa679b0a1d293a6 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Thu, 5 Oct 2023 09:38:53 +0800 Subject: [PATCH] Frontend Update visitor growth calculation display --- react-frontend/bun.lockb | Bin 148963 -> 148963 bytes react-frontend/src/pages/dashboard.tsx | 23 ++++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/react-frontend/bun.lockb b/react-frontend/bun.lockb index 3d485528ac08e96f3e6fb5e19f1aed43297da20c..72cec09e14af1085a3e38bfeba0331007a22a47a 100755 GIT binary patch delta 59 zcmaFd&H1>SvtbLP4~KwR7y}##Ffr9_FW_L@!!#X8ifq^6X7nv*XN)t_v(Pix-q6ID Gd>8<*5e}yS delta 57 zcmaFd&H1>SvtbLP4+j?m5LkXLwCM_+TqrKKy@7*q4b$`j4n~pfI^2xD { + const growth = visitorData[thisMonth]?.total + ? visitorData[thisMonth].total - + visitorData[thisMonth - 1]?.total ?? 0 + : 0 + + if (growth < 0) { + return `- ${Math.abs(growth)}` + } + + return `+ ${growth}` + } + return (

- {`+ ${ - visitorData[thisMonth]?.total ?? - 0 - - visitorData[thisMonth - 1] - ?.total ?? - 0 - } since last month`} + {`${getVisitorGrowth( + visitorData + )} since last month`}