mirror of
https://codeberg.org/MarkusThielker/finances.git
synced 2025-04-12 05:08:43 +00:00
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
import { getUser } from '@/auth';
|
|
import { prismaClient } from '@/prisma';
|
|
import React from 'react';
|
|
import PaymentPageClientContent from '@/components/paymentPageClientComponents';
|
|
import paymentCreateUpdate from '@/lib/actions/paymentCreateUpdate';
|
|
import paymentDelete from '@/lib/actions/paymentDelete';
|
|
|
|
export default async function PaymentsPage() {
|
|
|
|
const user = await getUser();
|
|
|
|
const payments = await prismaClient.payment.findMany({
|
|
where: {
|
|
userId: user?.id,
|
|
},
|
|
orderBy: [
|
|
{
|
|
date: 'desc',
|
|
},
|
|
{
|
|
id: 'desc',
|
|
},
|
|
],
|
|
});
|
|
|
|
const entities = await prismaClient.entity.findMany({
|
|
where: {
|
|
userId: user?.id,
|
|
},
|
|
orderBy: [
|
|
{
|
|
name: 'asc',
|
|
},
|
|
{
|
|
id: 'asc',
|
|
},
|
|
],
|
|
});
|
|
|
|
const categories = await prismaClient.category.findMany({
|
|
where: {
|
|
userId: user?.id,
|
|
},
|
|
orderBy: [
|
|
{
|
|
name: 'asc',
|
|
},
|
|
{
|
|
id: 'asc',
|
|
},
|
|
],
|
|
});
|
|
|
|
return (
|
|
<PaymentPageClientContent
|
|
payments={payments}
|
|
entities={entities}
|
|
categories={categories}
|
|
onSubmit={paymentCreateUpdate}
|
|
onDelete={paymentDelete}
|
|
className="flex flex-col justify-center space-y-4"/>
|
|
);
|
|
}
|