This commit is contained in:
Peter Maquiran
2024-02-29 09:40:51 +01:00
parent fcc75eb8e2
commit b47154d313
56 changed files with 225 additions and 3383 deletions
+30 -2
View File
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { Event, EventToApproveEdit } from '../models/event.model';
import { Event, EventToApproveEdit, } from '../models/event.model';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Observable, from } from 'rxjs';
import { environment } from 'src/environments/environment';
@@ -626,6 +626,11 @@ export class EventsService {
}
private deferenceBetweenDays(start: any, end: any) {
const diffTime = Math.abs(end - start);
return Math.ceil(diffTime / (1000 * 60 * 60 * 24));
}
async getEventsByCalendarId( startdate: string, enddate: string, calendarId: any) {
const calendars = SessionStore.user.OwnerCalendars.concat(SessionStore.user.SharedCalendars)
const agendasCalendars = calendars.filter( e => e.CalendarId == calendarId)
@@ -652,7 +657,30 @@ export class EventsService {
params: params
};
const calendar = await this.http.get<Event[]>(`${geturl}`, options).toPromise()
let calendar = await this.http.get<EventList[]>(`${geturl}`, options).toPromise()
calendar = calendar.map(e => {
if(e.IsAllDayEvent && this.deferenceBetweenDays(new Date(e.StartDate), new Date(e.EndDate)) >= 1) {
const date = new Date(e.EndDate);
date.setDate(date.getDate() -1);
const _date = date.getDate();
const month = date.getMonth() + 1;
const fullYear = date.getFullYear();
const formattedDate = `${fullYear}-${month}-${_date} 23:59`;
e.EndDate = formattedDate
console.log('reduze')
}
return e
})
console.log({calendar})
result = result.concat(calendar)
}