import { OptionalNullable } from '@humand-packages/common';
import { TimeTrackingPolicyAutoCloseMode } from '../enum/timeTracking/policy';
import { TimeTrackingPolicyApprovalStep } from './policies/approvalSteps/timeTrackingPolicyApprovalStep';

export class TimeTrackingPolicyForCreation {
    constructor(properties: OptionalNullable<TimeTrackingPolicyForCreation>) {
        this.allUsers = properties.allUsers;
        this.autoCloseLimitHours = properties.autoCloseLimitHours;
        this.autoCloseFixedHoursValue = properties.autoCloseFixedHoursValue ?? null;
        this.autoCloseFixedMinutesValue = properties.autoCloseFixedMinutesValue ?? null;
        this.autoCloseMode = properties.autoCloseMode;
        this.name = properties.name;
        this.description = properties.description;
        this.instanceId = properties.instanceId;
        this.clockingInAppEnabled = properties.clockingInAppEnabled;
        this.faceRecognitionEnabled = properties.faceRecognitionEnabled;
        this.faceRecognitionBlocking = properties.faceRecognitionBlocking;
        this.notificationsEnabled = properties.notificationsEnabled;
        this.nightShift = properties.nightShift;
        this.clockingInKioskEnabled = properties.clockingInKioskEnabled;
        this.clockingInWebEnabled = properties.clockingInWebEnabled;
        this.latenessTolerance = properties.latenessTolerance;
        this.geofencing = properties.geofencing;
        this.enableRemoteWork = properties.enableRemoteWork;
        this.saveRemoteWorkLocation = properties.saveRemoteWorkLocation;
    }

    allUsers!: boolean;
    name!: string;
    description!: string;
    instanceId!: number;
    clockingInAppEnabled!: boolean;
    faceRecognitionEnabled!: boolean;
    faceRecognitionBlocking!: boolean;
    notificationsEnabled!: boolean;
    nightShift!: boolean;
    clockingInKioskEnabled!: boolean;
    clockingInWebEnabled!: boolean;
    latenessTolerance?: number | null;
    generatePolicyHistoryFromDate?: Date | null;
    autoCloseLimitHours!: number;
    autoCloseMode!: TimeTrackingPolicyAutoCloseMode;
    autoCloseFixedHoursValue: number | null;
    autoCloseFixedMinutesValue: number | null;
    geofencing?: boolean | null;
    enableRemoteWork?: boolean | null;
    saveRemoteWorkLocation!: boolean;
}

export class TimeTrackingPolicy extends TimeTrackingPolicyForCreation {
    constructor(properties: OptionalNullable<TimeTrackingPolicy>) {
        super(properties);
        this.id = properties.id;
        this.userIds = properties.userIds;
        this.allUsers = properties.allUsers;
    }

    id!: number;
    userIds!: number[];
    allUsers!: boolean;
}

export class TimeTrackingPolicyWithApprovalSteps extends TimeTrackingPolicy {
    approvalSteps!: TimeTrackingPolicyApprovalStep[];
}

export class TimeTrackingPolicyAssociation {
    userId!: number;
    fromDate!: string;
    toDate?: string;
    policy?: TimeTrackingPolicy;
}

export class TimeTrackingPolicyAssociationData {
    fromDate!: string;
    userIds?: number[];
}
