Fix dashboard search filters
This commit is contained in:
@@ -15,7 +15,7 @@ export default async function AdsPage({ searchParams }: { searchParams: Promise<
|
|||||||
const mediaType = resolvedSearchParams.mediaType;
|
const mediaType = resolvedSearchParams.mediaType;
|
||||||
const where: Prisma.AdWhereInput = {};
|
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 (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;
|
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: { take: 1 }, savedBy: { where: { userId: user.id } } }, orderBy: { rankPercentile: "asc" }, take: 48 });
|
||||||
const isAdmin = user.role === "ADMIN";
|
const isAdmin = user.role === "ADMIN";
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ export default async function StoresPage({ searchParams }: { searchParams: Promi
|
|||||||
const q = resolvedSearchParams.q?.trim();
|
const q = resolvedSearchParams.q?.trim();
|
||||||
const niche = resolvedSearchParams.niche;
|
const niche = resolvedSearchParams.niche;
|
||||||
const where: Prisma.StoreWhereInput = {};
|
const where: Prisma.StoreWhereInput = {};
|
||||||
if (q) where.OR = [{ name: { contains: q, mode: "insensitive" } }, { domain: { contains: q, mode: "insensitive" } }];
|
if (q) where.OR = [{ name: { contains: q, mode: "insensitive" } }, { domain: { contains: q, mode: "insensitive" } }, { niche: { contains: q, mode: "insensitive" } }];
|
||||||
if (niche) where.niche = niche;
|
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 });
|
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 (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Reference in New Issue
Block a user