fix: add validation for DATE_DISPO to handle invalid date strings

This commit is contained in:
2026-02-13 16:54:14 +01:00
parent 0dfa9c285c
commit 0cb46014ff

View File

@@ -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 avgNote = noteP || noteA ? ((noteP + noteA) / (noteP && noteA ? 2 : 1)).toFixed(1) : null;
const dateDispo = annonce.DATE_DISPO const dateDispo = annonce.DATE_DISPO && annonce.DATE_DISPO.trim()
? new Date(annonce.DATE_DISPO).toLocaleDateString("fr-FR", { ? (() => {
day: "numeric", const date = new Date(annonce.DATE_DISPO);
month: "short", return isNaN(date.getTime()) ? null : date.toLocaleDateString("fr-FR", {
year: "numeric", day: "numeric",
}) month: "short",
year: "numeric",
});
})()
: null; : null;
const dateAjout = annonce.createdAt const dateAjout = annonce.createdAt