feat(admin): search posts by pet name in addition to caption
This commit is contained in:
1 parent
dd260bde9c
commit
48ce0396ca
2 files changed
+7
-2
No files matched your search
@@ -118,7 +118,7 @@ export default function AdminPostsPage() {
|
||||
))}
|
||||
</div>
|
||||
<Input
|
||||
placeholder="Search caption…"
|
||||
placeholder="Search caption or pet name…"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
className="w-64 bg-zinc-900 border-zinc-700 text-zinc-100 placeholder:text-zinc-500"
|
||||
|
||||
@@ -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 } },
|
||||
|
||||
Reference in new issue
Block a user