From 48ce0396ca6da91bef8ea3970be9f6bf67ca38b4 Mon Sep 17 00:00:00 2001 From: neodk2004 Date: Wed, 12 Aug 2026 08:09:25 +0200 Subject: [PATCH] feat(admin): search posts by pet name in addition to caption --- src/app/p/[secret]/posts/page.tsx | 2 +- src/trpc/routers/admin.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/p/[secret]/posts/page.tsx b/src/app/p/[secret]/posts/page.tsx index 5890481..0f58704 100644 --- a/src/app/p/[secret]/posts/page.tsx +++ b/src/app/p/[secret]/posts/page.tsx @@ -118,7 +118,7 @@ export default function AdminPostsPage() { ))} setSearch(e.target.value)} className="w-64 bg-zinc-900 border-zinc-700 text-zinc-100 placeholder:text-zinc-500" diff --git a/src/trpc/routers/admin.ts b/src/trpc/routers/admin.ts index 1062c25..24584ee 100644 --- a/src/trpc/routers/admin.ts +++ b/src/trpc/routers/admin.ts @@ -161,7 +161,12 @@ export const adminRouter = router({ await assertAdmin(ctx.prisma, ctx.userId); const posts = await ctx.prisma.post.findMany({ where: input.search - ? { caption: { contains: input.search, mode: "insensitive" } } + ? { + OR: [ + { caption: { contains: input.search, mode: "insensitive" } }, + { pet: { name: { contains: input.search, mode: "insensitive" } } }, + ], + } : undefined, include: { pet: { select: { id: true, name: true, avatarKey: true, ownerId: true } },