import { getServerSession } from 'next-auth'; import { authOptions } from '@/app/api/auth/[...nextauth]/route'; import { redirect } from 'next/navigation'; import { getAnnonceById } from '@/lib/services/annonceService'; import { getUserById } from '@/lib/services/userService'; import Link from 'next/link'; import ImageCarousel from '@/lib/components/ImageCarrousel'; export default async function AnnonceDetail({ params }: { params: { id: string } }) { const session = await getServerSession(authOptions); if (!session) redirect('/'); const annonce = await getAnnonceById(Number(params.id)); if (!annonce) return
Annonce non trouvée.
; const agent = await getUserById(annonce.agentId); const formattedPrice = new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR', minimumFractionDigits: 0 }).format(annonce.prix); const imageSrc = annonce.imagePrincipale ? `data:image/jpeg;base64,${Buffer.from(annonce.imagePrincipale).toString("base64")}` : "/default-image-annonce.jpg"; return (
← Retour aux annonces
{/* Colonne principale (Image et Description) */}
{/* Carrousel */}
{annonce.titre}
{/* Titre et Adresse */}

{annonce.titre}

{annonce.address}, {annonce.ville}

{/* Description */}

Description

{annonce.description || 'Aucune description.'}

{/* Prix et Agent */}
); }