Removed multiple day management (will be handled by server)

This commit is contained in:
Arnaud Vergnet 2020-03-21 21:10:57 +01:00
parent 3824683385
commit 53ef08219c

View file

@ -194,53 +194,16 @@ export default class PlanningScreen extends React.Component<Props, State> {
}
};
getClonedEventArray(event: Object, times: number) {
let cloneArray = [];
if (times > 1) {
for (let i = 0; i < times; i++) {
let clone = JSON.parse(JSON.stringify(event));
let startDate = PlanningEventManager.stringToDate(clone["date_begin"]);
let endDate = new Date();
if (i !== 0) {
startDate.setHours(0, 0, 0);
startDate.setDate(startDate.getDate() + i);
clone["date_begin"] = PlanningEventManager.dateToString(startDate);
}
if (i !== (times - 1)) {
endDate = PlanningEventManager.stringToDate(clone["date_end"]);
endDate.setHours(23, 59, 0);
endDate.setFullYear(startDate.getFullYear(),
startDate.getMonth(),
startDate.getDate() + i);
clone["date_end"] = PlanningEventManager.dateToString(endDate);
}
cloneArray.push(clone)
}
} else
cloneArray = [event];
return cloneArray;
}
generateEventAgenda(eventList: Array<Object>) {
let agendaItems = this.generateEmptyCalendar();
for (let i = 0; i < eventList.length; i++) {
if (PlanningEventManager.getDateOnlyString(eventList[i]["date_begin"]) !== undefined) {
const clonedEventArray = this.getClonedEventArray(
eventList[i],
PlanningEventManager.getEventDaysNumber(eventList[i]["date_begin"], eventList[i]["date_end"])
);
this.pushEvents(agendaItems, clonedEventArray);
this.pushEventInOrder(agendaItems, eventList[i], PlanningEventManager.getDateOnlyString(eventList[i]["date_begin"]));
}
}
this.setState({agendaItems: agendaItems})
}
pushEvents(agendaItems: Object, eventList: Array<Object>) {
for (let i = 0; i < eventList.length; i++) {
this.pushEventInOrder(agendaItems, eventList[i], PlanningEventManager.getDateOnlyString(eventList[i]["date_begin"]));
}
}
pushEventInOrder(agendaItems: Object, event: Object, startDate: string) {
if (agendaItems[startDate].length === 0)
agendaItems[startDate].push(event);