From 0cb46014ff48815ddeee9918d2de32a463a62695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C9=A7=CF=83=E2=84=93=CF=83?= Date: Fri, 13 Feb 2026 16:54:14 +0100 Subject: [PATCH] fix: add validation for DATE_DISPO to handle invalid date strings --- src/components/AppartCard.jsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/AppartCard.jsx b/src/components/AppartCard.jsx index 9b2178e..f51f82b 100644 --- a/src/components/AppartCard.jsx +++ b/src/components/AppartCard.jsx @@ -87,12 +87,15 @@ export default function AppartCard({ annonce, onDelete, onUpdated }) { const avgNote = noteP || noteA ? ((noteP + noteA) / (noteP && noteA ? 2 : 1)).toFixed(1) : null; - const dateDispo = annonce.DATE_DISPO - ? new Date(annonce.DATE_DISPO).toLocaleDateString("fr-FR", { - day: "numeric", - month: "short", - year: "numeric", - }) + const dateDispo = annonce.DATE_DISPO && annonce.DATE_DISPO.trim() + ? (() => { + const date = new Date(annonce.DATE_DISPO); + return isNaN(date.getTime()) ? null : date.toLocaleDateString("fr-FR", { + day: "numeric", + month: "short", + year: "numeric", + }); + })() : null; const dateAjout = annonce.createdAt