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

// ============================================================================
// User Types
// ============================================================================

export interface User {
  id: string;
  name: string;
  department: string;
  avatar?: string;
  birthYear?: number;
  zodiac?: string;
  joinDate?: Date;
  isActive: boolean;
  createdAt: Date;
}

export interface UserSession {
  sessionId: string;
  visitorId: string;
  userId: string;
  userName: string;
  role: 'user' | 'admin' | 'screen';
  createdAt: Date;
  lastActivity: Date;
  ipAddress?: string;
  userAgent?: string;
}

// ============================================================================
// Draw Types
// ============================================================================

export interface DrawParticipant {
  userId: string;
  userName: string;
  department: string;
  avatar?: string;
  zodiac?: string;
  birthYear?: number;
}

export interface DrawResult {
  id: string;
  drawId: string;
  prizeLevel: PrizeLevel;
  prizeName: string;
  winnerId: string;
  winnerName: string;
  winnerDepartment: string;
  drawnAt: Date;
  drawnBy: string; // Admin who triggered the draw
}

export interface DrawSession {
  id: string;
  prizeLevel: PrizeLevel;
  prizeName: string;
  totalPrizes: number;
  drawnCount: number;
  isActive: boolean;
  startedAt?: Date;
  endedAt?: Date;
  filters?: {
    excludeWinners: boolean;
    zodiacFilter?: string;
    ageRange?: { min?: number; max?: number };
    departments?: string[];
  };
}

export interface DrawHistory {
  sessions: DrawSession[];
  results: DrawResult[];
  totalParticipants: number;
  totalWinners: number;
}

// ============================================================================
// API Types
// ============================================================================

export interface StartDrawRequest {
  prizeLevel: PrizeLevel;
  prizeName: string;
  filters?: DrawSession['filters'];
}

export interface StartDrawResponse {
  success: boolean;
  drawId?: string;
  participantCount?: number;
  error?: string;
}

export interface GetDrawHistoryResponse {
  history: DrawHistory;
}
