/**
 * 작업 이력 관리 타입 정의 (프론트엔드)
 */

export type WorkType = 'inbound' | 'outbound' | 'transfer' | 'maintenance';
export type WorkStatus = 'pending' | 'in_progress' | 'completed' | 'cancelled';

export interface WorkHistory {
  id: number;
  work_number: string;
  work_date: string;
  work_type: WorkType;
  vehicle_number?: string;
  driver_name?: string;
  origin?: string;
  destination?: string;
  cargo_name?: string;
  cargo_weight?: number;
  cargo_unit?: string;
  distance?: number;
  distance_unit?: string;
  status: WorkStatus;
  scheduled_time?: string;
  start_time?: string;
  end_time?: string;
  estimated_arrival?: string;
  actual_arrival?: string;
  is_on_time?: boolean;
  delay_reason?: string;
  notes?: string;
  created_by?: string;
  created_at: string;
  updated_at: string;
}

export interface WorkHistoryStats {
  today_total: number;
  today_completed: number;
  total_weight: number;
  total_distance: number;
  on_time_rate: number;
  type_distribution: {
    inbound: number;
    outbound: number;
    transfer: number;
    maintenance: number;
  };
}

export interface MonthlyTrend {
  month: string;
  total: number;
  completed: number;
  weight: number;
  distance: number;
}

export interface TopRoute {
  origin: string;
  destination: string;
  count: number;
  total_weight: number;
}

// 한글 라벨
export const WORK_TYPE_LABELS: Record<WorkType, string> = {
  inbound: '입고',
  outbound: '출고',
  transfer: '이송',
  maintenance: '정비',
};

export const WORK_STATUS_LABELS: Record<WorkStatus, string> = {
  pending: '대기',
  in_progress: '진행중',
  completed: '완료',
  cancelled: '취소',
};

export const WORK_STATUS_COLORS: Record<WorkStatus, string> = {
  pending: 'bg-muted text-foreground',
  in_progress: 'bg-primary/10 text-primary',
  completed: 'bg-emerald-100 text-emerald-800',
  cancelled: 'bg-destructive/10 text-red-800',
};

