export interface FeatureControlData {
    id: number
    name: string
    slug: string
    is_enabled: boolean
    created_at: string
    updated_at: string
}

// The rules with settings of their own: 'sla' is the 30-minute reassignment, 'overdue' the overdue reassignment and
// 'lead_request' the daily transfer of approved lead requests (which only has closed weekdays and holidays).
export type SlaRule = 'sla' | 'overdue' | 'lead_request'

// A day on which one SLA does not run. A day that is a holiday for both SLAs is two entries.
export interface SlaHoliday {
    id: number
    date: string // 'YYYY-MM-DD', an IST calendar day
    rule: SlaRule
    reason: string | null
    status: 'past' | 'today' | 'upcoming'
    added_by: string | null
    created_at: string | null
}

export interface SlaHolidayList {
    today: string // today's IST date, 'YYYY-MM-DD'
    holidays: SlaHoliday[]
}

// Each SLA has its own working hours and closed weekdays: work_* / off_days are the 30-minute rule's,
// overdue_work_* / overdue_off_days the overdue rule's. Times are 'HH:MM', weekdays 0 = Sunday ... 6 = Saturday.
export interface SlaSettings {
    enabled: boolean
    overdue_enabled: boolean
    window_minutes: number
    work_start: string
    work_end: string
    off_days: number[]
    overdue_work_start: string
    overdue_work_end: string
    overdue_off_days: number[]
    overdue_hours: number
    lead_request_enabled: boolean
    lead_request_off_days: number[]
}

// Any subset of the hours and closed weekdays; what is left out stays as it is.
export type SlaWorkingHoursPayload = Partial<Pick<SlaSettings, 'work_start' | 'work_end' | 'off_days' | 'overdue_work_start' | 'overdue_work_end' | 'overdue_off_days' | 'lead_request_off_days'>>

// What a save marked, per SLA, and what was already marked there.
export interface AddSlaHolidaysResult {
    added: Partial<Record<SlaRule, string[]>>
    already_marked: Partial<Record<SlaRule, string[]>>
    leads_rescheduled: number
}
