/**
 * 근태 현황 (HR/Attendance) 변환
 */

import type { DailyAttendanceApiResponse } from '../types';
import type { DailyAttendanceData } from '@/components/business/CEODashboard/types';

const ATTENDANCE_STATUS_MAP: Record<string, '출근' | '휴가' | '지각' | '결근'> = {
  present: '출근',
  on_leave: '휴가',
  late: '지각',
  absent: '결근',
};

/**
 * DailyAttendance API 응답 → Frontend DailyAttendanceData 변환
 */
export function transformDailyAttendanceResponse(api: DailyAttendanceApiResponse): DailyAttendanceData {
  return {
    present: api.present,
    onLeave: api.on_leave,
    late: api.late,
    absent: api.absent,
    employees: api.employees.map((emp) => ({
      id: emp.id,
      department: emp.department,
      position: emp.position,
      name: emp.name,
      status: ATTENDANCE_STATUS_MAP[emp.status] ?? '출근',
    })),
  };
}
