From 959ae372134371f4cc2581c1dc6543dc3da072f0 Mon Sep 17 00:00:00 2001 From: PxlLoewe <72106766+PxlLoewe@users.noreply.github.com> Date: Wed, 16 Jul 2025 00:24:54 -0700 Subject: [PATCH] =?UTF-8?q?Nested-Suche=20hinzugef=C3=BCgt=20#59?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/_components/pagiantedTableActions.ts | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/apps/hub/app/_components/pagiantedTableActions.ts b/apps/hub/app/_components/pagiantedTableActions.ts index ca1a67a8..341e78b6 100644 --- a/apps/hub/app/_components/pagiantedTableActions.ts +++ b/apps/hub/app/_components/pagiantedTableActions.ts @@ -23,9 +23,26 @@ export async function getData( ? { OR: [ formattedId ? { id: formattedId } : undefined, - ...searchFields.map((field) => ({ - [field]: { contains: searchTerm }, - })), + ...searchFields.map((field) => { + if (field.includes(".")) { + const parts: string[] = field.split("."); + + // Helper function to build nested object + const buildNestedFilter = (parts: string[], index = 0): any => { + if (index === parts.length - 1) { + // Reached the last part - add the contains filter + return { [parts[index] as string]: { contains: searchTerm } }; + } + + // For intermediate levels, nest the next level + return { [parts[index] as string]: buildNestedFilter(parts, index + 1) }; + }; + + return buildNestedFilter(parts); + } + + return { [field]: { contains: searchTerm } }; + }), ].filter(Boolean), ...filter, }