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

export type AnnouncementStatus = ContentApprovalStatus;

export interface AnnouncementBase {
  id: number;
  organization_id: string;
  title: string;
  content: string;
  attachment_file_name: string | null;
  attachment_file_type: string | null;
  attachment_file_size: number | null;
  attachment_storage_key: string | null;
  attachment_file_url: string | null;
  start_date: string;
  end_date: string | null;
  is_pin: boolean;
  status: AnnouncementStatus;
  published_at: string | null;
  created_by: string;
  created_by_name: string | null;
  created_at: string;
  updated_at: string;
}

export interface AnnouncementWorkflowFields {
  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 AnnouncementPublic extends AnnouncementBase {}

export interface AnnouncementAdmin extends AnnouncementBase, AnnouncementWorkflowFields {}

export type Announcement = AnnouncementPublic | AnnouncementAdmin;

export interface AnnouncementFilters {
  page?: number;
  limit?: number;
  search?: string;
  status?: AnnouncementStatus;
  pin?: 'all' | 'pinned';
  sort?: string;
}

export interface AnnouncementsResponse {
  success: boolean;
  time: string;
  message: string;
  total_announcements: number;
  offset: number;
  limit: number;
  announcements: Announcement[];
}

export interface AnnouncementByIdResponse {
  success: boolean;
  time: string;
  message: string;
  announcement: Announcement;
}

export interface AnnouncementMutationPayload {
  title: string;
  content: string;
  startDate: string;
  endDate?: string | null;
  action: 'draft' | 'submit';
  removeAttachment?: boolean;
  attachment?: File | null;
}

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