import { type AgentEntity } from '../entities/agent.entity';

export const AGENT_REPOSITORY = Symbol('AGENT_REPOSITORY');

export interface AgentDashboardData {
  agentId: string;
  qualityScore: number;
  totalDeals: number;
  responseTimeAvg: number | null;
  isVerified: boolean;
  totalLeads: number;
  leadsByStatus: Record<string, number>;
  conversionRate: number;
  totalInquiries: number;
  unreadInquiries: number;
  totalListings: number;
  activeListings: number;
  avgReviewRating: number;
  totalReviews: number;
}

export interface AgentPublicListingItem {
  id: string;
  transactionType: string;
  priceVND: string;
  status: string;
  property: {
    id: string;
    title: string;
    propertyType: string;
    address: string;
    district: string;
    city: string;
    areaM2: number;
    bedrooms: number | null;
    bathrooms: number | null;
    imageUrl: string | null;
  };
}

export interface AgentPublicProfileData {
  id: string;
  fullName: string;
  avatarUrl: string | null;
  phone: string;
  email: string | null;
  agency: string | null;
  licenseNumber: string | null;
  bio: string | null;
  qualityScore: number;
  totalDeals: number;
  isVerified: boolean;
  serviceAreas: string[];
  memberSince: string;
  activeListings: AgentPublicListingItem[];
  avgReviewRating: number;
  totalReviews: number;
}

export interface QualityScoreInputData {
  avgRating: number;
  totalReviews: number;
  responseTimeAvg: number | null;
  conversionRate: number;
  activeListingRatio: number;
}

export interface IAgentRepository {
  findByUserId(userId: string): Promise<AgentEntity | null>;
  findById(agentId: string): Promise<AgentEntity | null>;
  save(agent: AgentEntity): Promise<void>;
  getDashboard(agentId: string): Promise<AgentDashboardData>;
  getPublicProfile(agentId: string): Promise<AgentPublicProfileData | null>;
  getQualityScoreInputs(agentId: string): Promise<QualityScoreInputData>;
}
