diff --git a/react-frontend/bun.lockb b/react-frontend/bun.lockb index 3d48552..72cec09 100755 Binary files a/react-frontend/bun.lockb and b/react-frontend/bun.lockb differ diff --git a/react-frontend/src/pages/dashboard.tsx b/react-frontend/src/pages/dashboard.tsx index 98c0ee4..9dff62a 100644 --- a/react-frontend/src/pages/dashboard.tsx +++ b/react-frontend/src/pages/dashboard.tsx @@ -108,6 +108,19 @@ export default function Dashboard() { const thisMonth = new Date().getMonth() + const getVisitorGrowth = (visitorData: VisitorData[]) => { + 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`}