fix: add validation for DATE_DISPO to handle invalid date strings
This commit is contained in:
@@ -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", {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user