|
|
@ -8,6 +8,8 @@ import parse from "date-fns/parse";
|
|
|
|
import startOfWeek from "date-fns/startOfWeek";
|
|
|
|
import startOfWeek from "date-fns/startOfWeek";
|
|
|
|
import { Calendar, dateFnsLocalizer } from "react-big-calendar";
|
|
|
|
import { Calendar, dateFnsLocalizer } from "react-big-calendar";
|
|
|
|
import "react-big-calendar/lib/css/react-big-calendar.css";
|
|
|
|
import "react-big-calendar/lib/css/react-big-calendar.css";
|
|
|
|
|
|
|
|
import Session from 'react-session-api'
|
|
|
|
|
|
|
|
import axios from 'axios'
|
|
|
|
|
|
|
|
|
|
|
|
const locales = {
|
|
|
|
const locales = {
|
|
|
|
'fr': require('date-fns/locale/fr')
|
|
|
|
'fr': require('date-fns/locale/fr')
|
|
|
@ -18,18 +20,57 @@ const locales = {
|
|
|
|
startOfWeek,
|
|
|
|
startOfWeek,
|
|
|
|
getDay,
|
|
|
|
getDay,
|
|
|
|
locales,
|
|
|
|
locales,
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const api = axios.create({
|
|
|
|
|
|
|
|
baseURL: 'http://localhost:8080'
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const apiStringGetEvent = '/edt/' + Session.get("idUser");
|
|
|
|
|
|
|
|
|
|
|
|
const events = [
|
|
|
|
const events = []
|
|
|
|
|
|
|
|
|
|
|
|
];
|
|
|
|
const recupererEvents = () => {
|
|
|
|
|
|
|
|
// api.get(apiStringGetEvent).then((response) => {
|
|
|
|
|
|
|
|
// response.forEach(element => {
|
|
|
|
|
|
|
|
// events.push({
|
|
|
|
|
|
|
|
// title: element.Comment,
|
|
|
|
|
|
|
|
// start: new Date(element.jour+" "+element.StartTime),
|
|
|
|
|
|
|
|
// end: new Date(element.jour+" "+element.EndTime)
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
const event = []
|
|
|
|
|
|
|
|
if (localStorage.getItem("events") !== null &&localStorage.getItem("events") !== "" && localStorage.getItem("events") !== []) {
|
|
|
|
|
|
|
|
JSON.parse(localStorage.getItem("events")).forEach(element => {
|
|
|
|
|
|
|
|
event.push({
|
|
|
|
|
|
|
|
title: element.title,
|
|
|
|
|
|
|
|
start: new Date(element.start),
|
|
|
|
|
|
|
|
end: new Date(element.end)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return event
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const envoyerNouvelleEvent = (event) => {
|
|
|
|
|
|
|
|
// const apiStringPostEvent = '/edt/' + Session.get("idUser");
|
|
|
|
|
|
|
|
// api.post(apiStringPostEvent, {
|
|
|
|
|
|
|
|
// Comment: event.title,
|
|
|
|
|
|
|
|
// jour: event.start,
|
|
|
|
|
|
|
|
// StartTime: event.start,
|
|
|
|
|
|
|
|
// EndTime: event.end
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Calendrier = () => {
|
|
|
|
const Calendrier = () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [theme, setTheme] = useState("light");
|
|
|
|
const [theme, setTheme] = useState("light");
|
|
|
|
if (localStorage.getItem('theme') && localStorage.getItem("theme") !== '' && localStorage.getItem("theme") !== theme) {
|
|
|
|
if (localStorage.getItem('theme') && localStorage.getItem("theme") !== '' && localStorage.getItem("theme") !== theme) {
|
|
|
|
setTheme(localStorage.getItem("theme"))
|
|
|
|
setTheme(localStorage.getItem("theme"))
|
|
|
@ -39,13 +80,15 @@ const Calendrier = () => {
|
|
|
|
const [heureDebut, setHeureDebut] = useState(new Date());
|
|
|
|
const [heureDebut, setHeureDebut] = useState(new Date());
|
|
|
|
const [heureFin, setHeureFin] = useState(new Date());
|
|
|
|
const [heureFin, setHeureFin] = useState(new Date());
|
|
|
|
|
|
|
|
|
|
|
|
const [allEvents, setAllEvents] = useState(events);
|
|
|
|
const [allEvents, setAllEvents] = useState(recupererEvents);
|
|
|
|
|
|
|
|
|
|
|
|
function handleAddEvent() {
|
|
|
|
function handleAddEvent() {
|
|
|
|
const newEvent = { title: titre, start: new Date(jour+" "+heureDebut), end: new Date(jour+" "+heureFin) };
|
|
|
|
const newEvent = { title: titre, start: new Date(jour+" "+heureDebut), end: new Date(jour+" "+heureFin) };
|
|
|
|
setAllEvents([...allEvents, newEvent]);
|
|
|
|
setAllEvents([...allEvents, newEvent]);
|
|
|
|
|
|
|
|
localStorage.setItem("events", JSON.stringify([...allEvents, newEvent]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<body className={theme}>
|
|
|
|
<body className={theme}>
|
|
|
|
|
|
|
|
|
|
|
|