Fix dashboard search filters

This commit is contained in:
2026-07-08 11:52:05 +03:00
parent 9edf6ac794
commit 4e8dcf207d
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ export default async function AdsPage({ searchParams }: { searchParams: Promise<
const mediaType = resolvedSearchParams.mediaType;
const where: Prisma.AdWhereInput = {};
if (q) where.OR = [{ primaryText: { contains: q, mode: "insensitive" } }, { headline: { contains: q, mode: "insensitive" } }, { brandPage: { name: { contains: q, mode: "insensitive" } } }];
if (niche) where.niche = niche;
if (niche) where.niche = { contains: niche, mode: "insensitive" };
if (mediaType) where.mediaType = mediaType as any;
const ads = await prisma.ad.findMany({ where, include: { brandPage: true, creatives: { take: 1 }, savedBy: { where: { userId: user.id } } }, orderBy: { rankPercentile: "asc" }, take: 48 });
const isAdmin = user.role === "ADMIN";
+2 -2
View File
@@ -10,8 +10,8 @@ export default async function StoresPage({ searchParams }: { searchParams: Promi
const q = resolvedSearchParams.q?.trim();
const niche = resolvedSearchParams.niche;
const where: Prisma.StoreWhereInput = {};
if (q) where.OR = [{ name: { contains: q, mode: "insensitive" } }, { domain: { contains: q, mode: "insensitive" } }];
if (niche) where.niche = niche;
if (q) where.OR = [{ name: { contains: q, mode: "insensitive" } }, { domain: { contains: q, mode: "insensitive" } }, { niche: { contains: q, mode: "insensitive" } }];
if (niche) where.niche = { contains: niche, mode: "insensitive" };
const stores = await prisma.store.findMany({ where, include: { products: { where: { isBestSeller: true }, take: 2 }, brandPages: { include: { _count: { select: { ads: true } } }, take: 1 } }, orderBy: { estRevenue30dMax: "desc" }, take: 50 });
return (
<div>