export type CoursePurchaseStatus = "pending" | "paid" | "failed" | "cancelled"

/** How the learner owns the course: a paid order, or a former purchase the coach imported (technical-plan 4.7). */
export type CourseOwnership = "purchase" | "import"

export interface ICourseLesson {
  id: number
  title: string
  description: string | null
  avatar: string | null
  sort_code: number | null
  status: boolean | null
  is_free_preview: boolean
  duration_seconds: number | null
  /** The learner's progress in this lesson. */
  done?: boolean
  position_seconds?: number
}

export interface IPigment {
  key: string
  name: string
  hex: string
}

export interface IColourRecipe {
  name: string
  parts: { pigment: string | null; parts: number; name: string | null; hex: string | null }[]
}

export interface ICourseProgress {
  done_count: number
  total: number
  percent: number
  continue_lesson_id: number | null
}

export interface ICourseCoach {
  name: string
  slug: string | null
  field: string | null
  verified: boolean
  avatar: string | null
  critique_price: number | null
}

export interface ICourse {
  id: number
  title: string
  description: string | null
  cover: string | null
  price: number
  start_date: string
  end_date: string
  is_purchasable: boolean
  purchase_status: CoursePurchaseStatus | null
  ownership?: CourseOwnership | null
  payment_method: string | null
  coach?: ICourseCoach | null
  slug?: string | null
  subtitle?: string | null
  category?: { key: string; title: string; icon: string | null } | null
  level?: { value: string; label: string } | null
  medium?: { key: string; label: string } | null
  hours?: number | null
  materials?: string[]
  palette?: IPigment[]
  recipes?: IColourRecipe[]
  /** Active lessons in course order (sort_code), each with the learner's progress. */
  lessons: ICourseLesson[]
  lessons_count?: number
  progress?: ICourseProgress
}
