From bb4f832d749582765fd2235fa6a6f624045628d6 Mon Sep 17 00:00:00 2001 From: Markus Thielker <mail.markus.thielker@gmail.com> Date: Mon, 11 Mar 2024 03:55:33 +0100 Subject: [PATCH] N-FIN-12: show account statistics --- src/app/account/page.tsx | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/app/account/page.tsx b/src/app/account/page.tsx index 1b6d787..4cd88f9 100644 --- a/src/app/account/page.tsx +++ b/src/app/account/page.tsx @@ -9,6 +9,7 @@ import SignOutForm from '@/components/form/signOutForm'; import { URL_SIGN_IN } from '@/lib/constants'; import GenerateSampleDataForm from '@/components/form/generateSampleDataForm'; import generateSampleData from '@/lib/actions/generateSampleData'; +import { prismaClient } from '@/prisma'; export default async function AccountPage() { @@ -18,6 +19,28 @@ export default async function AccountPage() { redirect(URL_SIGN_IN); } + let paymentCount = 0; + let entityCount = 0; + let categoryCount = 0; + + if (process.env.NODE_ENV === 'development') { + paymentCount = await prismaClient.payment.count({ + where: { + userId: user.id, + }, + }); + entityCount = await prismaClient.entity.count({ + where: { + userId: user.id, + }, + }); + categoryCount = await prismaClient.category.count({ + where: { + userId: user.id, + }, + }); + } + return ( <div className="flex flex-col items-center"> <Card className="w-full max-w-md mt-12"> @@ -38,6 +61,26 @@ export default async function AccountPage() { disabled value={user?.username}/> </div> + <div className="flex flex-row items-center space-x-4"> + <div> + <Label>Payments</Label> + <Input + disabled + value={paymentCount}/> + </div> + <div> + <Label>Entities</Label> + <Input + disabled + value={entityCount}/> + </div> + <div> + <Label>Categories</Label> + <Input + disabled + value={categoryCount}/> + </div> + </div> </CardContent> <CardFooter className="space-x-4"> {