export interface User {
  email: string
  name: string
  is_admin: boolean
  caps: string[]
}

export function can(user: User, cap: string): boolean {
  return user.is_admin || user.caps.includes(cap)
}

export interface DayData {
  total_servicing: number
  departs: number
  stays: number
  arrivals: number
  pickup_hint: number
  pickup_lead: number
  prior_occ: number
  prior_vac: number
  delta_new: number
  delta_cancelled: number
}

export interface Category {
  id: string
  name: string
  total_rooms: number
  days: Record<string, DayData>
}

export interface BookingsData {
  dates: string[]
  categories: Category[]
  last_viewed: string
}

export type TimeReqs = Record<string, { depart: number; stay: number; arrive: number }>

export interface StaffMember {
  name: string
  hours: Record<string, number>
}

export interface GeneralTask {
  name: string
  hours: Record<string, number>
}

export type PickupData = Record<string, Record<string, { count: number; total: number }>>

export interface Adjustment {
  label: string
  hours: Record<string, number>  // YYYY-MM-DD → positive or negative hours
}

export interface WfShiftDay {
  hours: number
  times: string
}

export interface WfStaffMember {
  id: string
  name: string
  days: Record<string, WfShiftDay>
}

export interface WfDayData {
  synced_at: string
  source: string
  staff: { id: string; name: string; hours: number; times: string }[]
}

export interface RequiredDay {
  booked: number
  pickup: number
  general: number
  adjustments: number
  total: number
  by_cat: Record<string, number>
  pickup_by_cat: Record<string, number>
}
