import type { VoteCategory } from './socket.types';

// ============================================================================
// Candidate Types
// ============================================================================

export interface Candidate {
  id: string;
  name: string;
  department: string;
  avatar?: string;
  description?: string;
  category: VoteCategory;
  createdAt: Date;
}

export interface CandidateWithVotes extends Candidate {
  voteCount: number;
  rank?: number;
  percentage?: number;
}

// ============================================================================
// Vote Types
// ============================================================================

export interface Vote {
  id: string;
  odrawId: string;
  userId: string;
  candidateId: string;
  category: VoteCategory;
  createdAt: Date;
}

export interface VoteStats {
  candidateId: string;
  category: VoteCategory;
  totalVotes: number;
  percentage: number;
  rank: number;
}

export interface CategoryVoteStats {
  category: VoteCategory;
  totalVotes: number;
  candidates: VoteStats[];
  updatedAt: Date;
}

// ============================================================================
// Voting Session Types
// ============================================================================

export interface VotingSession {
  id: string;
  name: string;
  startTime: Date;
  endTime: Date;
  isActive: boolean;
  maxVotesPerUser: number;
  categories: VoteCategory[];
}

export interface UserVoteStatus {
  userId: string;
  votedCategories: VoteCategory[];
  remainingVotes: number;
  votes: Array<{
    category: VoteCategory;
    candidateId: string;
    votedAt: Date;
  }>;
}

// ============================================================================
// API Request/Response Types
// ============================================================================

export interface SubmitVoteRequest {
  candidateId: string;
  category: VoteCategory;
}

export interface SubmitVoteResponse {
  success: boolean;
  voteId?: string;
  newCount?: number;
  error?: string;
}

export interface GetCategoryResultsRequest {
  category: VoteCategory;
  limit?: number;
}

export interface GetCategoryResultsResponse {
  category: VoteCategory;
  results: CandidateWithVotes[];
  totalVotes: number;
  updatedAt: Date;
}
