/**
 * 캘린더 (Calendar) 변환
 */

import type { CalendarApiResponse } from '../types';
import type { CalendarScheduleItem } from '@/components/business/CEODashboard/types';

/**
 * Calendar API 응답 → Frontend 타입 변환
 * API 응답 형식이 CalendarScheduleItem과 동일하므로 단순 매핑
 */
export function transformCalendarResponse(api: CalendarApiResponse): {
  items: CalendarScheduleItem[];
  totalCount: number;
} {
  return {
    items: api.items.map((item) => ({
      id: item.id,
      title: item.title,
      startDate: item.startDate,
      endDate: item.endDate,
      startTime: item.startTime ?? undefined,
      endTime: item.endTime ?? undefined,
      isAllDay: item.isAllDay,
      type: item.type,
      department: item.department ?? undefined,
      personName: item.personName ?? undefined,
      color: item.color ?? undefined,
    })),
    totalCount: api.total_count,
  };
}
