diff --git a/src/components/IncompleteEvent/IncompleteEvent.jsx b/src/components/IncompleteEvent/IncompleteEvent.jsx index b5d83c7..ed4ac34 100644 --- a/src/components/IncompleteEvent/IncompleteEvent.jsx +++ b/src/components/IncompleteEvent/IncompleteEvent.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from "react"; import styles from "./IncompleteEvent.module.css"; -import getAllEvents from "../../utils/event/getAllEvents"; +import getAllEvents from "../../utils/events/getAllEvents"; function IncompleteEvent() { const [events, setEvents] = useState([]); diff --git a/src/components/chart/ParticipationChart.jsx b/src/components/chart/ParticipationChart.jsx index 90581b3..18aac36 100644 --- a/src/components/chart/ParticipationChart.jsx +++ b/src/components/chart/ParticipationChart.jsx @@ -3,7 +3,7 @@ import { Doughnut } from "react-chartjs-2"; import { Chart, ArcElement } from "chart.js"; import { MenuItem, Select, FormControl } from "@mui/material"; import styles from "./ParticipationChart.module.css"; -import getAllEvents from "../../utils/event/getAllEvents"; +import getAllEvents from "../../utils/events/getAllEvents"; Chart.register(ArcElement); diff --git a/src/utils/date/formatDateLetter.js b/src/utils/date/formatDateLetter.js index 3480835..883b3c8 100644 --- a/src/utils/date/formatDateLetter.js +++ b/src/utils/date/formatDateLetter.js @@ -1,14 +1,23 @@ + + export function formatDateLetter(d) { + if (!d) return "Date inconnue"; + + const dateObj = new Date(d); + if (isNaN(dateObj.getTime())) return "Date invalide"; + const monthNames = [ "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre" ]; - const [datePart, timePart] = d.split(' '); - const [year, month, day] = datePart.split('-'); - const [hours, minutes] = timePart.split(':'); + const day = dateObj.getDate().toString().padStart(2, "0"); + const month = monthNames[dateObj.getMonth()]; + const year = dateObj.getFullYear(); + const hours = dateObj.getHours().toString().padStart(2, "0"); + const minutes = dateObj.getMinutes().toString().padStart(2, "0"); - return `${day} ${monthNames[parseInt(month, 10) - 1]} ${year} à ${hours}:${minutes}`; + return `${day} ${month} ${year} à ${hours}:${minutes}`; } @@ -19,4 +28,5 @@ export function formatDateLetterJS(d) { ]; const [year, month, day] = d.split('-'); return `${day} ${monthNames[parseInt(month) - 1]} ${year}`; -} \ No newline at end of file +} +