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, }