diff --git a/screens/Planning/PlanningScreen.js b/screens/Planning/PlanningScreen.js index de40716..67e30e9 100644 --- a/screens/Planning/PlanningScreen.js +++ b/screens/Planning/PlanningScreen.js @@ -194,53 +194,16 @@ export default class PlanningScreen extends React.Component { } }; - 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) { 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) { - 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);