Frontend Update visitor growth calculation display

pull/3/head
TZGyn 2 years ago
parent fa3abc523b
commit f16c2d4aef
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

Binary file not shown.

@ -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 (
<ThemeProvider
defaultTheme='dark'
@ -153,13 +166,9 @@ export default function Dashboard() {
{visitorData[thisMonth]?.total ?? 0}
</div>
<p className='text-xs text-muted-foreground'>
{`+ ${
visitorData[thisMonth]?.total ??
0 -
visitorData[thisMonth - 1]
?.total ??
0
} since last month`}
{`${getVisitorGrowth(
visitorData
)} since last month`}
</p>
</CardContent>
</Card>

Loading…
Cancel
Save