export const SHIFT_TYPES: ShiftType[] = [
    'REGULAR',
    'EVENING',
    'EMERGENCY',
    'HOLIDAY',
    'VACATION',
    'SICK'
];

export type ShiftType = 'REGULAR' | 'EVENING' | 'EMERGENCY' | 'HOLIDAY' | 'VACATION' | 'SICK';

export type ShiftErrorCode = 'SHIFT_OVERLAP' | 'MISSING_START_TIME' | 'MISSING_END_TIME' | 'COMMENT_LENGTH_EXCEEDED' | 'APPROVAL_LOCK' | 'INVALID_DATE' | 'INVALID TYPE' | 'INVALID_TIMESHEET';

export type ShiftLegendItem = {
    type: ShiftType;
    color: string;
    label_type: string;
    text_color?: string;
};

export class Shift {
    id: number;
    timesheet_id: number;
    date: string;    //YYYY-MM-DD
    type: ShiftType;
    start_time: string;    //HH:mm:ss
    end_time: string;    //HH:mm:ss
    comment: string | undefined;
    is_approved: boolean;
    is_remote: boolean;
    has_error: boolean;

    constructor() {
        this.id = -1;
        this.timesheet_id = -1;
        this.date = '';
        this.type = 'REGULAR';
        this.start_time = '';
        this.end_time = '';
        this.comment = undefined;
        this.is_approved = false;
        this.is_remote = false;
        this.has_error = false;
    }
}

export interface ShiftOption {
    label: string;
    value: ShiftType;
    icon: string;
    icon_color: string;
}

export interface ShiftAPIResponse {
    ok: boolean;
    data?: {
        shift: Shift;
        overtime: unknown;
    }
    error?: ShiftAPIError;
}

export interface ShiftAPIError {
    error_code: ShiftErrorCode;
    conflicts:
    {
        date: string;
        start_time: string;
        end_time: string;
    }
}