// Data types for HiHala Dashboard

export interface MuseumRecord {
  date: string;
  museum_code: string;
  museum_name: string;
  district: string;
  visits: number;
  tickets: number;
  revenue_gross: number;
  revenue_net: number;
  revenue_incl_tax: number; // Legacy field
  year: string;
  quarter: string;
}

export interface Metrics {
  revenue: number;
  visitors: number;
  tickets: number;
  avgRevPerVisitor: number;
}

export interface Filters {
  year: string;
  district: string;
  museum: string;
  quarter: string;
}

export interface DateRangeFilters {
  district: string;
  museum: string;
}

export interface CacheStatus {
  available: boolean;
  timestamp: string | null;
  age: number | null;
  rows: number;
  isStale?: boolean;
}

export interface CacheResult {
  data: MuseumRecord[];
  isStale: boolean;
  timestamp: number;
}

export interface FetchResult {
  data: MuseumRecord[];
  fromCache: boolean;
  cacheTimestamp?: number;
}

export interface GroupedData {
  revenue: number;
  visitors: number;
  tickets: number;
}

export interface DistrictMuseumMap {
  [district: string]: string[];
}

export interface UmrahData {
  [year: number]: {
    [quarter: number]: number | null;
  };
}

// Chart data types
export interface ChartDataset {
  label?: string;
  data: number[];
  backgroundColor?: string | string[];
  borderColor?: string;
  borderWidth?: number;
  borderRadius?: number;
  tension?: number;
  fill?: boolean;
  pointRadius?: number;
  pointHoverRadius?: number;
  pointBackgroundColor?: string;
  pointBorderColor?: string;
  pointBorderWidth?: number;
  yAxisID?: string;
  order?: number;
  datalabels?: object;
}

export interface ChartData {
  labels: string[];
  datasets: ChartDataset[];
}

// Component props
export interface DashboardProps {
  data: MuseumRecord[];
  showDataLabels: boolean;
  setShowDataLabels: (value: boolean) => void;
  includeVAT: boolean;
  setIncludeVAT: (value: boolean) => void;
}

export interface ComparisonProps {
  data: MuseumRecord[];
  showDataLabels: boolean;
  setShowDataLabels: (value: boolean) => void;
  includeVAT: boolean;
  setIncludeVAT: (value: boolean) => void;
}

export interface SlidesProps {
  data: MuseumRecord[];
}

// Quarterly table row
export interface QuarterlyRow {
  q: number;
  rev24: number;
  rev25: number;
  revChg: number;
  vis24: number;
  vis25: number;
  visChg: number;
  cap24: number | null;
  cap25: number | null;
}

// Metric card for comparison
export interface MetricCardData {
  title: string;
  prev: number | null;
  curr: number | null;
  change: number | null;
  isCurrency?: boolean;
  isPercent?: boolean;
  pendingMessage?: string;
}

// NocoDB raw types
export interface NocoDBDistrict {
  Id: number;
  Name: string;
}

export interface NocoDBMuseum {
  Id: number;
  Code: string;
  Name: string;
  'nc_epk____Districts_id': number;
}

export interface NocoDBDailyStat {
  Id: number;
  Date: string;
  Visits: number;
  Tickets: number;
  GrossRevenue: number;
  NetRevenue: number;
  'nc_epk____Museums_id': number;
}

// Translation function type
export type TranslateFunction = (key: string) => string;
