import { WORKDAYS } from '@humand-packages/common';
import { SiteBasicDTO } from '../../../regions/presentation/dataTransferObjects/sitesDTO';
import { AutoCloseFallback } from '../../business/enum/timeTracking/autoCloseFallback';
import { ShiftAssociation } from '../../business/models/shiftManagement/shiftCalendar';
import { TimeSlot } from '../../business/models/timeTracking/scheduleData';
import { TimeTrackingDaySummaryHolidayApi } from '../../business/models/timeTrackingDaySummaryHoliday';
import { TimeTrackingDaySummaryTimeOffApi } from '../../business/models/timeTrackingDaySummaryTimeOff';
import { TimeTrackingEntryType } from '../../business/types/entry';
import { DaySummaryScheduleSource } from '../../business/types/scheduleSource';
import { TimeTrackingEntrySource } from '../../business/types/source';
import { Incidence } from '../../infrastructure/constants/incidences';
import { TimeTrackingAppGrant } from '../constants/timeTrackingGrants';

export interface CoordinatesDTO {
    latitude: number;
    longitude: number;
}

export interface TimeTrackingDaySummaryCategorizedHourDTO {
    category: {
        name: string;
        description: string | null;
    };
    hours: number;
}

export interface TimeTrackingDaySummaryHoursDTO {
    worked: number;
    scheduled: number;
    estimated: number;
    extra: number;
    timeOff: number | null;
}

export interface TimeTrackingDaySummaryScheduleDTO {
    source: DaySummaryScheduleSource;
    workSchedule: { id: number; name: string; description: string | null } | null;
    shiftAssociations: ShiftAssociation[] | null;
}

export interface TimeTrackingDaySummaryEntryDTO {
    id: number;
    type: TimeTrackingEntryType;
    userId: number;
    time: Date;
    date: Date;
    source: TimeTrackingEntrySource;
    site?: SiteBasicDTO;
    siteName?: string;
    coordinates?: CoordinatesDTO;
    comment?: string;
    locationIncidence?: boolean;
    isRemoteWork?: boolean;
    autoCloseFallback?: AutoCloseFallback | null;
    createdAt?: Date;
    updatedAt?: Date;
}

export interface TimeTrackingDaySummaryUserDTO {
    id: number;
    firstName: string;
    lastName: string;
    profilePicture: string | null;
}

export interface TimeTrackingDaySummaryDTO {
    id: number;
    date: Date;
    dateString: string;
    userId: number;
    user: TimeTrackingDaySummaryUserDTO;
    weekday: WORKDAYS;
    isWorkday: boolean;
    nightShift: boolean;
    schedule: TimeTrackingDaySummaryScheduleDTO;
    hours: TimeTrackingDaySummaryHoursDTO;
    categorizedHours: TimeTrackingDaySummaryCategorizedHourDTO[];
    timeSlots: TimeSlot[];
    entries: TimeTrackingDaySummaryEntryDTO[];
    holidays: TimeTrackingDaySummaryHolidayApi[];
    timeOffRequests: TimeTrackingDaySummaryTimeOffApi[];
    incidences: Incidence[];
    grants?: TimeTrackingAppGrant[];
}
