export interface CalendarRecord {
  id: string;
  name: string;
  type: "system" | "family";
  color: string;
  created_at: string;
}

export interface EventRecord {
  id: string;
  calendar_id: string;
  title: string;
  description: string | null;
  notes: string | null;
  start_time: string;
  end_time: string;
  all_day: number; // 0 or 1
  location: string | null;
  recurrence_rule: string | null;
  created_by: string;
  created_at: string;
  updated_at: string;
}

export interface EventPersonRecord {
  event_id: string;
  person_name: string;
  invite_preference: "calendar_invite" | "reminder_only" | "both" | "none";
  invite_sent: number;
  reminder_sent: number;
  google_event_id: string | null;
}

export interface ReminderRecord {
  id: string;
  event_id: string;
  person_name: string;
  remind_at: string;
  sent: number;
  sent_at: string | null;
}

export interface GoogleCachedEventRecord {
  id: string;
  google_calendar_id: string;
  google_calendar_name: string;
  google_event_id: string;
  title: string;
  description: string | null;
  start_time: string;
  end_time: string;
  all_day: number;
  location: string | null;
  person_email: string;
  last_synced: string;
}

// API request/response types
export interface CreateEventRequest {
  calendar_id: string;
  title: string;
  description?: string;
  notes?: string;
  start_time: string;
  end_time: string;
  all_day?: boolean;
  location?: string;
  recurrence_rule?: string;
  created_by: string;
  people?: {
    person_name: string;
    invite_preference: "calendar_invite" | "reminder_only" | "both" | "none";
  }[];
  reminders?: {
    person_name: string;
    remind_at: string;
  }[];
}

export interface UpdateEventRequest {
  title?: string;
  description?: string;
  notes?: string;
  start_time?: string;
  end_time?: string;
  all_day?: boolean;
  location?: string;
  recurrence_rule?: string;
  people?: {
    person_name: string;
    invite_preference: "calendar_invite" | "reminder_only" | "both" | "none";
  }[];
}

export interface EventWithPeople extends EventRecord {
  people: EventPersonRecord[];
  reminders: ReminderRecord[];
}
