import { EntityState, createEntityAdapter } from '@ngrx/entity';
import { DisplayInfoDTO, DisplayInfoRequest } from '@swagger/eis';
import { getMinAndMaxDate } from '../../../modules/task-calendar/helpers';

export interface TaskCalendarState extends EntityState<DisplayInfoDTO> {
  fetching: boolean;
  filter?: DisplayInfoRequest;
}

const { minDate, maxDate } = getMinAndMaxDate(3);

export const taskCalendarAdapter = createEntityAdapter<DisplayInfoDTO>();

export const INITIAL_TASK_CALENDAR_STATE: TaskCalendarState = {
  ...taskCalendarAdapter.getInitialState(),
  fetching: false,
  filter: {
    branchId: undefined,
    start: minDate.toISOString(),
    stop: maxDate.toISOString(),
    infoOnly: false,
    categories: [],
    includeDisplayTimespan: true,
  },
};
