feat: implement business detail client view with interactive features including rating, favoriting, messaging, and analytics tracking

This commit is contained in:
2026-05-09 21:12:01 +02:00
parent 6a42c52b58
commit 6acd5ebe2e
14 changed files with 516 additions and 40 deletions

View File

@@ -8,6 +8,7 @@ export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url)
const category = searchParams.get('category')
const q = searchParams.get('q')?.toLowerCase()
const location = searchParams.get('location')?.toLowerCase()
const featured = searchParams.get('featured')
const countryId = searchParams.get('countryId')
@@ -19,11 +20,12 @@ export async function GET(request: NextRequest) {
isSuspended: false
}
}
// Build the conditions array
const conditions: any[] = [];
if (category && category !== 'All') {
// Robust check: IDs are usually alphanumeric and long, without spaces or special chars
// Names like "Agriculture & Agrobusiness" have spaces or special chars.
const isId = /^[a-z0-9-]+$/.test(category) && category.length > 20;
if (isId) {
where.categoryId = category
} else {
@@ -32,13 +34,30 @@ export async function GET(request: NextRequest) {
}
if (featured === 'true') where.isFeatured = true
if (countryId) where.countryId = countryId
if (q) {
where.OR = [
{ name: { contains: q, mode: 'insensitive' } },
{ description: { contains: q, mode: 'insensitive' } },
// Simplified tags check
{ tags: { has: q } }
]
conditions.push({
OR: [
{ name: { contains: q, mode: 'insensitive' } },
{ description: { contains: q, mode: 'insensitive' } },
{ city: { contains: q, mode: 'insensitive' } },
{ location: { contains: q, mode: 'insensitive' } },
{ tags: { has: q } }
]
});
}
if (location) {
conditions.push({
OR: [
{ city: { contains: location, mode: 'insensitive' } },
{ location: { contains: location, mode: 'insensitive' } }
]
});
}
if (conditions.length > 0) {
where.AND = conditions;
}
const dbBusinesses = await prisma.business.findMany({