/**
 * Recurring Tasks & Templates TypeScript types — recurring-tasks-templates.
 * Shared between API handlers and React components.
 */

// ── Domain objects (JSON-serialized, safe for API responses) ─────────────────

export type RecurringTaskPriority = 'low' | 'medium' | 'high' | 'urgent'

export interface RecurringTaskObject {
  id: string
  tenant_id: string
  project_id: string | null
  title: string
  description: string | null
  assignee_id: string | null
  estimated_hours: number | null
  priority: RecurringTaskPriority
  labels: string[]
  /** RFC 5545 RRULE string, e.g. 'FREQ=WEEKLY;BYDAY=MO' */
  recurrence: string
  /** Create instance N days before due date */
  advance_days: number
  status_id: string | null
  is_active: boolean
  created_by: string
  created_at: string
  last_generated_at: string | null
}

export interface TaskTemplateObject {
  id: string
  tenant_id: string
  /** Template display name */
  name: string
  /** Task title; may contain {{customer}}, {{project}} variables */
  title: string
  description: string | null
  estimated_hours: number | null
  priority: RecurringTaskPriority
  labels: string[]
  created_by: string
  created_at: string
}

// ── Mutation input shapes ────────────────────────────────────────────────────

export interface CreateRecurringTaskInput {
  title: string
  description?: string | null
  project_id?: string | null
  assignee_id?: string | null
  estimated_hours?: number | null
  priority?: RecurringTaskPriority
  labels?: string[]
  recurrence: string
  advance_days: number
  status_id?: string | null
}

export interface UpdateRecurringTaskInput {
  title?: string
  description?: string | null
  project_id?: string | null
  assignee_id?: string | null
  estimated_hours?: number | null
  priority?: RecurringTaskPriority
  labels?: string[]
  recurrence?: string
  advance_days?: number
  status_id?: string | null
  is_active?: boolean
}

export interface CreateTaskTemplateInput {
  name: string
  title: string
  description?: string | null
  estimated_hours?: number | null
  priority?: RecurringTaskPriority
  labels?: string[]
}
