From 4fd7c8d45784cbf7682a0751d3d9efa6ff169686 Mon Sep 17 00:00:00 2001 From: Hikmet Date: Tue, 11 Aug 2026 11:32:53 +0300 Subject: [PATCH] fix: hide ads without media creatives --- src/app/dashboard/ads/page.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/dashboard/ads/page.tsx b/src/app/dashboard/ads/page.tsx index ab793b4..19a00bc 100644 --- a/src/app/dashboard/ads/page.tsx +++ b/src/app/dashboard/ads/page.tsx @@ -15,11 +15,21 @@ export default async function AdsPage({ searchParams }: { searchParams: Promise< const q = resolvedSearchParams.q?.trim(); const niche = resolvedSearchParams.niche; const mediaType = resolvedSearchParams.mediaType; - const where: Prisma.AdWhereInput = {}; + const displayableCreativeWhere: Prisma.AdCreativeWhereInput = { url: { not: "" } }; + const where: Prisma.AdWhereInput = { creatives: { some: displayableCreativeWhere } }; if (q) where.OR = [{ primaryText: { contains: q, mode: "insensitive" } }, { headline: { contains: q, mode: "insensitive" } }, { brandPage: { name: { contains: q, mode: "insensitive" } } }]; 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 ads = await prisma.ad.findMany({ + where, + include: { + brandPage: true, + creatives: { where: displayableCreativeWhere, orderBy: { position: "asc" }, take: 1 }, + savedBy: { where: { userId: user.id } } + }, + orderBy: { rankPercentile: "asc" }, + take: 48 + }); const isAdmin = user.role === "ADMIN"; const apifyPlanLimit = isAdmin || plan?.code === "PREMIUM" ? 100 : plan?.code === "STANDARD" ? 50 : plan?.code === "BASIC" ? 25 : 0; const masked = ads.map((ad) => maskAdForPlan({ ...ad, isSaved: ad.savedBy.length > 0 }, plan?.code, isAdmin));