feat(expenses): enhance expenses management with filtering and search capabilities
This commit is contained in:
@@ -88,12 +88,20 @@ export async function listExpenses(params: {
|
||||
status?: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
periodicExpenseId?: number;
|
||||
search?: string;
|
||||
}) {
|
||||
const { status, page = 1, pageSize = 10 } = params;
|
||||
const { status, page = 1, pageSize = 10, periodicExpenseId, search } = params;
|
||||
const where: Record<string, unknown> = {};
|
||||
if (status === "PENDING" || status === "PAYED") {
|
||||
where.status = status;
|
||||
}
|
||||
if (periodicExpenseId !== undefined) {
|
||||
where.periodicExpenseId = periodicExpenseId;
|
||||
}
|
||||
if (search) {
|
||||
where.description = { contains: search, mode: "insensitive" };
|
||||
}
|
||||
const [data, total] = await Promise.all([
|
||||
prisma.expense.findMany({
|
||||
where,
|
||||
|
||||
Reference in New Issue
Block a user