remove console logs

This commit is contained in:
Peter Maquiran
2024-10-24 10:50:46 +01:00
parent 08f68940dc
commit 41dfb448dd
7 changed files with 10 additions and 220 deletions
@@ -1,110 +0,0 @@
// calendar.actions.ts
import { createAction, props } from '@ngrx/store';
import { createReducer, on } from '@ngrx/store';
import { EventList, EventListStore } from 'src/app/models/agenda/AgendaEventList';
import { createFeatureSelector, createSelector } from '@ngrx/store';
export const loadEvents = createAction('[Calendar] Load Events');
export const loadEventsSuccess = createAction(
'[Calendar] Load Events Success',
props<{ events: EventListStore[] }>()
);
export const resetList = createAction(
'[Calendar] Reset List',
props<{ eventSource: EventListStore[] }>()
);
export const pushEvent = createAction(
'[Calendar] Push Event',
props<{ eventsList: EventList[], profile: 'pr' | 'md', userId: string }>()
);
export const removeRangeForCalendar = createAction(
'[Calendar] Remove Range For Calendar',
props<{ startDate: Date, endDate: Date, userId: string }>()
);
export const getRangeForCalendar = createAction(
'[Calendar] Remove Range For Calendar',
props<{ startDate: Date, endDate: Date, userId: string }>()
);
export const deleteAllEvents = createAction('[Calendar] Delete All Events');
// =========================================================================
export interface CalendarState {
eventSource: EventListStore[];
}
export const initialState: CalendarState = {
eventSource: []
};
export const calendarReducer = createReducer(
initialState,
on(loadEventsSuccess, (state, { events }) => ({
...state,
eventSource: events
})),
on(resetList, (state, { eventSource }) => ({
...state,
eventSource
})),
on(pushEvent, (state, { eventsList, profile, userId }) => {
let news = eventsList.map(element => ({
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
calendarName: element.CalendarName,
profile: profile,
id: element.EventId,
CalendarId: userId
}));
let instance = state.eventSource.concat(news as any);
const ids = instance.map(o => o.id);
const filtered = instance.filter(({ id }, index) => !ids.includes(id, index + 1));
return {
...state,
eventSource: filtered
};
}),
on(removeRangeForCalendar, (state, { startDate, endDate, userId }) => ({
...state,
eventSource: state.eventSource.filter(e =>
!(new Date(e.endTime).getTime() >= new Date(startDate).getTime() &&
new Date(endDate).getTime() >= new Date(e.startTime).getTime() && e.CalendarId == userId)
)
})),
on(deleteAllEvents, state => ({
...state,
eventSource: []
}))
);
// =========================================================================
export const selectCalendarState = createFeatureSelector<CalendarState>('calendar');
export const selectEventSource = createSelector(
selectCalendarState,
(state: CalendarState) => state.eventSource
);
// Create selector to get range of events
export const selectEventsInRange = (startDate: Date, endDate: Date, userId: string) => createSelector(
selectEventSource,
(events) => events.filter(event =>
new Date(event.startTime).getTime() >= new Date(startDate).getTime() &&
new Date(event.endTime).getTime() <= new Date(endDate).getTime() &&
event.CalendarId === userId
)
);
@@ -17,8 +17,6 @@ import { EventUpdateInputDTOSchema } from '../dto/eventUpdateInputDtO';
import { AttachInputDTOSchema } from '../dto/addAttachmentDTOInput';
import { EventListDataOutputDTOSchema } from '../dto/eventListDTOOutput';
import { EventSearchMapper } from '../../domain/mapper/EventSearchMapper';
import { Store } from '@ngrx/store';
import { CalendarState } from '../data-source/agenda-memory-source.service';
import { NativeNotificationService } from 'src/app/services/native-notification.service';
import { ListBoxService } from 'src/app/ui/agenda/service/list-box.service';
import { EventListStore } from 'src/app/models/agenda/AgendaEventList';
@@ -37,7 +35,6 @@ export class AgendaDataRepositoryService {
private agendaDataService: AgendaDataService,
private utils: Utils,
private agendaLocalDataSourceService: AgendaLocalDataSourceService,
private memoryStore: Store<CalendarState>,
private NativeNotificationService: NativeNotificationService,
public listBoxService: ListBoxService,
) { }