import type { AppRole } from "@/lib/constants";

export type Profile = {
  id: string;
  email: string;
  role: AppRole;
  created_at: string;
};

export type Country = {
  id: number;
  code: string;
  name: string;
};

export type ViewerContext = {
  userId: string;
  email: string;
  role: AppRole;
  allowedCountries: string[];
};

export type ImportStatus = "processing" | "completed" | "failed";

export type ParsedEventRow = {
  primary_country_code: string;
  approved_document_name: string;
  sent_email_name: string;
  brand?: string;
  last_open: string | null;
  opened: number;
  total_opens: number;
  last_click: string | null;
  clicked: number;
  total_clicks: number;
  sent_date: string | null;
  source_row_number: number;
  source_sheet_name?: string;
};

export type ImportParseResult = {
  rows: ParsedEventRow[];
  previewRows: ParsedEventRow[];
  documentBrands: Record<string, string>;
  sentimentByEmail: Record<string, { thumbs_up: number; thumbs_down: number }>;
  sentimentRows: number;
  warnings: string[];
  errors: string[];
  detectedCountries: string[];
};

export type KPISet = {
  total_emails_sent: number;
  total_opened: number;
  total_opens: number;
  total_clicked: number;
  total_clicks: number;
  open_rate: number;
  ctr: number;
  ctor: number;
};
