import type { ContentApprovalStatus } from '@/features/content-approval/lib/workflow';
import type { OnlineLessonCategory } from '../constants/categories';

export type { OnlineLessonCategory } from '../constants/categories';

export type OnlineLessonStatus = ContentApprovalStatus;

export type OnlineLessonVideoType = 'url' | 'upload' | 'none';

export interface OnlineLesson {
  id: number;
  organization_id: string;
  title: string;
  description: string | null;
  category: OnlineLessonCategory | null;
  video_url: string | null;
  video_file_url: string | null;
  video_file_name: string | null;
  attachment_url: string | null;
  attachment_name: string | null;
  thumbnail_url: string | null;
  status: OnlineLessonStatus;
  is_published: boolean;
  published_at: string | null;
  created_at: string;
  updated_at: string;
  video_type: OnlineLessonVideoType;
  created_by?: string;
  created_by_name?: string | null;
  updated_by?: string | null;
  updated_by_name?: string | null;
  submitted_at?: string | null;
  submitted_by?: string | null;
  reviewed_at?: string | null;
  reviewed_by?: string | null;
  approved_at?: string | null;
  approved_by?: string | null;
  published_by?: string | null;
  review_comment?: string | null;
}

export interface OnlineLessonFilters {
  page?: number;
  limit?: number;
  search?: string;
  status?: OnlineLessonStatus;
  category?: OnlineLessonCategory;
}

export interface OnlineLessonsResponse {
  success: boolean;
  time: string;
  message: string;
  total_online_lessons: number;
  offset: number;
  limit: number;
  online_lessons: OnlineLesson[];
  categories?: OnlineLessonCategory[];
}

export interface OnlineLessonByIdResponse {
  success: boolean;
  time: string;
  message: string;
  online_lesson: OnlineLesson;
}

export interface OnlineLessonMutationPayload {
  title: string;
  description?: string;
  category?: OnlineLessonCategory;
  videoUrl?: string;
  action?: 'draft' | 'submit';
  removeVideoFile?: boolean;
  removeAttachment?: boolean;
  removeThumbnail?: boolean;
  videoFile?: File | null;
  attachmentFile?: File | null;
  thumbnailFile?: File | null;
}

export interface OnlineLessonWorkflowActionPayload {
  action?: 'submit' | 'approve' | 'return' | 'reject' | 'publish' | 'archive';
  status?: OnlineLessonStatus;
  comment?: string;
}
