import { OptionalNullable } from '@humand-packages/common';
import { SiteBasicDTO } from '../../../regions/presentation/dataTransferObjects/sitesDTO';
import { LocationVC } from '../../presentation/validationClasses/locationValidationClass';
import { AutoCloseFallback } from '../enum/timeTracking/autoCloseFallback';
import { TimeTrackingEntryType } from '../types/entry';
import { TimeTrackingEntrySource } from '../types/source';
import { TimeTrackingKiosk } from './timeTrackingKiosk';

export class TimeTrackingEntryPrototype {
    constructor(properties: OptionalNullable<TimeTrackingEntryPrototype>) {
        this.type = properties.type;
        this.userId = properties.userId;
        this.time = properties.time;
        this.siteId = properties.siteId;
        this.location = properties.location;
        this.createdBy = properties.createdBy;
        this.source = properties.source;
        this.summaryId = properties.summaryId;
        this.comment = properties.comment;
        this.facialRecognitionSkipped = properties.facialRecognitionSkipped;
        this.kioskId = properties.kioskId;
        this.instanceId = properties.instanceId;
        this.eventTime = properties.eventTime;
        this.deletedBy = properties.deletedBy;
        this.updatedBy = properties.updatedBy;
        this.desertEagleEntryId = properties.desertEagleEntryId;
        this.isRemoteWork = properties.isRemoteWork;
        this.autoCloseFallback = properties.autoCloseFallback ?? null;
    }

    type: TimeTrackingEntryType;
    userId: number;
    time: Date;
    siteId?: number;
    source: TimeTrackingEntrySource;
    location?: LocationVC;
    createdBy?: number;
    deletedBy?: number;
    updatedBy?: number;
    summaryId?: number;
    comment?: string;
    facialRecognitionSkipped?: boolean;
    kioskId?: number;
    instanceId?: number;
    eventTime?: Date | null;
    desertEagleEntryId?: string | null;
    isRemoteWork?: boolean;
    autoCloseFallback?: AutoCloseFallback | null;
}

export class TimeTrackingEntry extends TimeTrackingEntryPrototype {
    constructor(properties: OptionalNullable<TimeTrackingEntry>) {
        super(properties);
        this.id = properties.id;
        this.locationIncidence = properties.locationIncidence;
        this.kiosk = properties.kiosk;
        this.createdAt = properties.createdAt;
        this.updatedAt = properties.updatedAt;
    }

    id: number;
    locationIncidence?: boolean;
    kiosk?: TimeTrackingKiosk;
    createdAt?: Date;
    updatedAt?: Date;
}

export class TimeTrackingEntryUpdate extends TimeTrackingEntryPrototype {
    constructor(properties: OptionalNullable<TimeTrackingEntryUpdate>) {
        super(properties);
        this.id = properties.id;
    }

    id?: number;
}

export class TimeTrackingEntryApi {
    constructor(properties: OptionalNullable<TimeTrackingEntryApi>) {
        this.id = properties.id;
        this.date = properties.date;
        this.referenceDate = properties.referenceDate;
        this.type = properties.type;
        this.userId = properties.userId;
        this.time = properties.time;
        this.site = properties.site;
        this.source = properties.source;
        this.coordinates = properties.coordinates;
        this.comment = properties.comment;
        this.employeeId = properties.employeeId;
        this.autoCloseFallback = properties.autoCloseFallback ?? null;
        this.createdAt = properties.createdAt;
        this.updatedAt = properties.updatedAt;
    }

    id: number;
    date: Date;
    referenceDate: string;
    type: TimeTrackingEntryType;
    userId: number;
    time: Date;
    site?: SiteBasicDTO;
    source: TimeTrackingEntrySource;
    coordinates?: LocationVC;
    comment?: string;
    employeeId?: string;
    autoCloseFallback?: AutoCloseFallback | null;
    createdAt?: Date;
    updatedAt?: Date;
}

export class TimeTrackingEntryBasicData {
    constructor(properties: OptionalNullable<TimeTrackingEntryBasicData>) {
        this.id = properties.id;
        this.time = properties.time;
        this.type = properties.type;
    }

    id: number;
    time: Date;
    type: TimeTrackingEntryType;
}
