import type { Product } from "./product";

export interface DashboardRankingItem {
  label: string;
  count: number;
  total_spent?: number;
}

export interface DashboardCategoryItem {
  label: string;
  count: number;
  claimed_count: number;
}

export interface DashboardAttentionItem {
  label: string;
  average_rating: number;
  count: number;
}

export interface DashboardAttentionFeedbackItem {
  id: number;
  incident_number: string;
  title: string;
  store_label: string;
  brand_label: string;
  rating: number;
  notes: string;
  updated_at: string;
}

export interface ActiveIncidentItem {
  id: number;
  incident_number: string;
  title: string;
  status: string;
  product_name: string;
  product_brand: string;
  product_model: string;
  product_days_remaining: number;
  updated_at: string;
}

export interface ConsumerDashboardSummary {
  warranty: {
    total: number;
    active: number;
    warning: number;
    critical: number;
    expired: number;
    expiringSoon: Product[];
  };
  claims: {
    total: number;
    active: number;
    resolved: number;
    closed: number;
    claimedProducts: number;
    claimRate: number;
    avgRating: number | null;
    topBrands: DashboardRankingItem[];
    topProducts: DashboardRankingItem[];
  };
  incidents: {
    active: number;
    items: ActiveIncidentItem[];
  };
  attention: {
    avgRating: number | null;
    ratedIncidents: number;
    topStores: DashboardAttentionItem[];
    topBrands: DashboardAttentionItem[];
    recentFeedback: DashboardAttentionFeedbackItem[];
    publicAvgRating: number | null;
    publicRatedIncidents: number;
    publicTopStores: DashboardAttentionItem[];
    publicTopBrands: DashboardAttentionItem[];
    publicFeedback: DashboardAttentionFeedbackItem[];
  };
  stores: {
    totalStores: number;
    topStores: DashboardRankingItem[];
  };
  consumer: {
    totalSpent: number;
    avgPurchasePrice: number | null;
    productsWithoutReceipt: number;
    extendedCoverage: number;
    insuranceCoverage: number;
    coverageMix: DashboardRankingItem[];
    categoryComparison: DashboardCategoryItem[];
    documentsTotal: number;
    documentsWithTracking: number;
  };
}
