// Types for equipment management

export interface EquipmentAlert {
  id: string;
  type: 'warning' | 'critical' | 'info';
  message: string;
  timestamp: string;
  acknowledged: boolean;
}

export interface MaintenanceHistory {
  id: string;
  date: string;
  type: 'preventive' | 'corrective' | 'emergency';
  description: string;
  technician: string;
  cost: number;
  downtime: number; // hours
  partsUsed: string[];
}

export interface EquipmentSpecifications {
  power: number; // kW
  capacity: number;
  dimensions: {
    width: number;
    height: number;
    depth: number;
  };
  weight: number;
}

export interface Equipment {
  id: string;
  tenant_id?: string;
  name: string;
  type: 'oven' | 'mixer' | 'proofer' | 'freezer' | 'packaging' | 'other';
  model: string;
  serialNumber: string;
  location: string;
  status: 'operational' | 'maintenance' | 'down' | 'warning';
  installDate: string;
  lastMaintenance: string;
  nextMaintenance: string;
  maintenanceInterval: number; // days
  temperature?: number;
  targetTemperature?: number;
  efficiency: number;
  uptime: number;
  energyUsage: number;
  utilizationToday: number;
  alerts: EquipmentAlert[];
  maintenanceHistory: MaintenanceHistory[];
  specifications: EquipmentSpecifications;
  is_active?: boolean;
  support_contact?: {
    email?: string;
    phone?: string;
    company?: string;
    contract_number?: string;
    response_time_sla?: number;
  };
  created_at?: string;
  updated_at?: string;
}

// API Request/Response types
export type EquipmentType = 'oven' | 'mixer' | 'proofer' | 'freezer' | 'packaging' | 'other';
export type EquipmentStatus = 'operational' | 'maintenance' | 'down' | 'warning';

export interface EquipmentCreate {
  name: string;
  type: EquipmentType;
  model?: string;
  serial_number?: string;
  location?: string;
  status?: EquipmentStatus;
  install_date?: string;
  last_maintenance_date?: string;
  next_maintenance_date?: string;
  maintenance_interval_days?: number;
  efficiency_percentage?: number;
  uptime_percentage?: number;
  energy_usage_kwh?: number;
  power_kw?: number;
  capacity?: number;
  weight_kg?: number;
  current_temperature?: number;
  target_temperature?: number;
  notes?: string;
  support_contact?: {
    email?: string;
    phone?: string;
    company?: string;
    contract_number?: string;
    response_time_sla?: number;
  };
}

export interface EquipmentUpdate {
  name?: string;
  type?: EquipmentType;
  model?: string;
  serial_number?: string;
  location?: string;
  status?: EquipmentStatus;
  install_date?: string;
  last_maintenance_date?: string;
  next_maintenance_date?: string;
  maintenance_interval_days?: number;
  efficiency_percentage?: number;
  uptime_percentage?: number;
  energy_usage_kwh?: number;
  power_kw?: number;
  capacity?: number;
  weight_kg?: number;
  current_temperature?: number;
  target_temperature?: number;
  is_active?: boolean;
  notes?: string;
}

export interface EquipmentResponse {
  id: string;
  tenant_id: string;
  name: string;
  type: EquipmentType;
  model: string | null;
  serial_number: string | null;
  location: string | null;
  status: EquipmentStatus;
  install_date: string | null;
  last_maintenance_date: string | null;
  next_maintenance_date: string | null;
  maintenance_interval_days: number | null;
  efficiency_percentage: number | null;
  uptime_percentage: number | null;
  energy_usage_kwh: number | null;
  power_kw: number | null;
  capacity: number | null;
  weight_kg: number | null;
  current_temperature: number | null;
  target_temperature: number | null;
  is_active: boolean;
  notes: string | null;
  support_contact: {
    email?: string;
    phone?: string;
    company?: string;
    contract_number?: string;
    response_time_sla?: number;
  } | null;
  created_at: string;
  updated_at: string;
}

export interface EquipmentListResponse {
  equipment: EquipmentResponse[];
  total_count: number;
  page: number;
  page_size: number;
}

export interface EquipmentDeletionSummary {
  can_delete: boolean;
  warnings: string[];
  production_batches_count: number;
  maintenance_records_count: number;
  temperature_logs_count: number;
  equipment_name?: string;
  equipment_type?: string;
  equipment_location?: string;
}