continue Event page

This commit is contained in:
PxlLoewe
2025-02-17 10:39:29 +01:00
parent 8928455c3a
commit 30af30bd1d
13 changed files with 242 additions and 227 deletions

View File

@@ -1,5 +1,5 @@
"use server";
import { PrismaClient } from "@repo/db";
'use server';
import { PrismaClient } from '@repo/db';
const prisma = new PrismaClient();
@@ -8,7 +8,9 @@ export async function getData(
limit: number,
offset: number,
searchTerm: string,
searchFields: string[]
searchFields: string[],
filter?: Record<string, any>,
include?: Record<string, boolean>[]
) {
if (!model || !prisma[model]) {
return { data: [], total: 0 };
@@ -24,8 +26,9 @@ export async function getData(
[field]: { contains: searchTerm },
})),
].filter(Boolean),
...filter,
}
: {};
: { ...filter };
if (!prisma[model]) {
return { data: [], total: 0 };
@@ -35,6 +38,7 @@ export async function getData(
where,
take: limit,
skip: offset,
include,
});
const total = await (prisma[model] as any).count({ where });