|
|
@ -12,8 +12,6 @@ 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 api = axios.create({
|
|
|
|
const api = axios.create({
|
|
|
@ -31,50 +29,11 @@ const localizer = dateFnsLocalizer({
|
|
|
|
locales,
|
|
|
|
locales,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const apiStringGetEvent = '/edt/' + Session.get("idUser");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Calendrier(){
|
|
|
|
function Calendrier(){
|
|
|
|
|
|
|
|
|
|
|
|
const [contacts, setContacts] = useState([]);
|
|
|
|
const [contacts, setContacts] = useState([]);
|
|
|
|
const [events, setEvents] = useState([]);
|
|
|
|
const [events, setEvents] = useState([]);
|
|
|
|
const [selectedContact, setSelectedContact] = useState(1);
|
|
|
|
const [selectedContact, setSelectedContact] = useState(1);
|
|
|
|
const envoyerNouvelleEvent = (event) => {
|
|
|
|
|
|
|
|
// const apiStringPostEvent = '/edt/' + Session.get("idUser");
|
|
|
|
|
|
|
|
// api.post(apiStringPostEvent, {
|
|
|
|
|
|
|
|
// Comment: event.title,
|
|
|
|
|
|
|
|
// jour: event.start,
|
|
|
|
|
|
|
|
// StartTime: event.start,
|
|
|
|
|
|
|
|
// EndTime: event.end
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() =>{
|
|
|
|
useEffect(() =>{
|
|
|
|
const apiString = '/Contact/' + Session.get("idUser");
|
|
|
|
const apiString = '/Contact/' + Session.get("idUser");
|
|
|
@ -105,7 +64,7 @@ const envoyerNouvelleEvent = (event) => {
|
|
|
|
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(recupererEvents);
|
|
|
|
const [allEvents, setAllEvents] = useState(events);
|
|
|
|
|
|
|
|
|
|
|
|
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) };
|
|
|
@ -114,7 +73,6 @@ const envoyerNouvelleEvent = (event) => {
|
|
|
|
console.log(response.data);
|
|
|
|
console.log(response.data);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
setAllEvents([...allEvents, newEvent]);
|
|
|
|
setAllEvents([...allEvents, newEvent]);
|
|
|
|
localStorage.setItem("events", JSON.stringify([...allEvents, newEvent]));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function handleChangeContact(event){
|
|
|
|
function handleChangeContact(event){
|
|
|
|