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';
export default async function AnnonceDetail({ params }: { params: { id: string } }) {
const session = await getServerSession(authOptions);
if (!session) {
redirect('/');
}
const annonceId = await getAnnonceById(Number(params.id));
const agent = await getUserById(annonceId?.agentId || 0);
return (
Détails de l'annonce
Agent ID: {annonceId?.agentId}
Description: {annonceId?.description || 'Aucune description disponible.'}
Prix: {annonceId?.prix} €
Contactez l'agent
Pour plus d'informations, veuillez contacter l'agent responsable de cette annonce.
{agent ? (
Nom: {agent.firstName} {agent.lastName}
Email: {agent.email}
) : (
Informations sur l'agent non disponibles.
)}
);
}