N-FIN-12: show account statistics
This commit is contained in:
parent
e83558dfef
commit
bb4f832d74
1 changed files with 43 additions and 0 deletions
|
@ -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">
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue