/**
 * Blog Management Types
 * Type definitions for blog post management in staff dashboard
 */

export type BlogStatus = 'DRAFT' | 'PUBLISHED' | 'ARCHIVED';

export interface BlogPostDB {
  id: string;
  slug: string;
  lang: 'ar' | 'en';
  title: string;
  excerpt: string;
  content: string;
  cover_image: string | null;
  author: string;
  tags: string[];
  published: boolean;
  status: BlogStatus;
  featured: boolean;
  featured_order: number | null;
  meta_title: string | null;
  meta_description: string | null;
  meta_keywords: string[] | null;
  og_image: string | null;
  reading_time_minutes: number | null;
  date: string;
  published_at: string | null;
  created_at: string;
  updated_at: string;
}

export interface BlogPostListItem {
  id: string;
  slug: string;
  lang: 'ar' | 'en';
  title: string;
  excerpt: string;
  cover_image: string | null;
  author: string;
  tags: string[];
  status: BlogStatus;
  featured: boolean;
  date: string;
  published_at: string | null;
  created_at: string;
  updated_at: string;
}

export interface CreateBlogPostInput {
  slug: string;
  lang: 'ar' | 'en';
  title: string;
  excerpt: string;
  content: string;
  author: string;
  tags?: string[];
  status?: BlogStatus;
  featured?: boolean;
  featured_order?: number;
  meta_title?: string;
  meta_description?: string;
  meta_keywords?: string[];
  date?: string;
  generateAiImage?: boolean; // Whether to generate AI image
}

export interface UpdateBlogPostInput {
  slug?: string;
  title?: string;
  excerpt?: string;
  content?: string;
  author?: string;
  tags?: string[];
  status?: BlogStatus;
  featured?: boolean;
  featured_order?: number;
  meta_title?: string;
  meta_description?: string;
  meta_keywords?: string[];
  date?: string;
  published_at?: string;
  cover_image?: string;
  regenerateAiImage?: boolean; // Whether to regenerate AI image
}

export interface BlogPostFilters {
  status?: BlogStatus;
  lang?: 'ar' | 'en';
  featured?: boolean;
  tags?: string[];
  search?: string; // Search in title, excerpt, content
  author?: string;
  dateFrom?: string;
  dateTo?: string;
}

export interface PaginatedBlogPosts {
  posts: BlogPostListItem[];
  total: number;
  page: number;
  pageSize: number;
  totalPages: number;
}

export interface BlogStats {
  total: number;
  byStatus: {
    draft: number;
    published: number;
    archived: number;
  };
  byLanguage: {
    ar: number;
    en: number;
  };
  featured: number;
  recentlyPublished: number; // Last 7 days
}

export interface ImageUploadResult {
  publicUrl: string;
  path: string;
  bucket: string;
}
