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 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
|
||||||
|
|||||||
Reference in New Issue
Block a user