import { getTranslations, setRequestLocale } from 'next-intl/server' import { mockDb } from '@/lib/mockDb' import Navbar from '@/components/Navbar' import Footer from '@/components/Footer' import ListingCard from '@/components/ListingCard' import { notFound } from 'next/navigation' import Image from 'next/image' import { Phone, Globe, MapPin, Clock, Star, MessageSquare } from 'lucide-react' interface DetailPageProps { params: Promise<{ locale: string; category: string; slug: string }> } export default async function ListingDetailPage({ params }: DetailPageProps) { const { locale, category, slug } = await params setRequestLocale(locale) const t = await getTranslations('detail') const listing = await mockDb.getListingBySlug(slug) if (!listing) { notFound() } // Fetch similar listings in same category (limit to 3, excluding current) const allCategoryListings = await mockDb.getListings({ categoryId: listing.categoryId }) const relatedListings = allCategoryListings .filter(l => l.id !== listing.id) .slice(0, 3) // Localized values const name = locale === 'ru' ? listing.nameRu : locale === 'en' ? listing.nameEn : listing.nameTr const description = locale === 'ru' ? listing.descriptionRu : locale === 'en' ? listing.descriptionEn : listing.descriptionTr const priceSymbols = '₺'.repeat(listing.priceRange) // Format WhatsApp Link const getWhatsAppLink = (number: string) => { // Clean spaces, parenthesis, plus sign const cleanNum = number.replace(/\D/g, '') return `https://wa.me/${cleanNum}` } return (
{/* Breadcrumb / Category Link */}
marmaris local / {locale === 'ru' ? listing.category?.nameRu : locale === 'en' ? listing.category?.nameEn : listing.category?.nameTr} / {name}
{/* Hero Details Block */}
{/* Left: Gallery Panel */}
0 ? listing.images[0].url : 'https://images.unsplash.com/photo-1555396273-367ea4eb4db5?w=800&auto=format&fit=crop&q=80'} alt={name} fill priority className="object-cover" />
{/* Thumbnails if multiple images exist */} {listing.images && listing.images.length > 1 && (
{listing.images.slice(1, 5).map((img, idx) => (
{`${name}
))}
)}
{/* Right: Info Panel */}
{/* Badge & Title */}
{locale === 'ru' ? listing.category?.nameRu : locale === 'en' ? listing.category?.nameEn : listing.category?.nameTr} {listing.isLocalApproved && ( ★ {t('approved')} )}

{name}

{/* Stars and Price level */}
{listing.rating && (
{t('rating')}: {listing.rating.toFixed(1)}
)}
{t('price')}: {priceSymbols}
{/* Description */}
{description}
{/* Contact Actions */}

{t('contact')}

{listing.phone && ( {t('call')} )} {listing.whatsapp && ( {t('whatsapp')} )}
{/* External links */}
{listing.website && ( {t('website')} )} {listing.instagram && ( {t('instagram')} )}
{/* Details footer (Hours & Location map) */}
{/* Address */}
{t('address')}

{listing.address}

{/* Hours */}
{t('hours')}
{listing.openingHours ? (

{(listing.openingHours as any).all || t('noHours')}

) : (

{t('noHours')}

)}
{/* Map Frame */} {listing.latitude && listing.longitude && (
{t('location')}