import type {
  CampusAttendanceConfigDto,
  CampusAttendanceSummaryDto,
  CampusAttendanceSummaryMutationDto,
} from '@/shared/types/campusAttendance';
import type {
  CampusAttendanceConfigViewModel,
  CampusAttendanceEntryInput,
  CampusAttendanceSummaryViewModel,
} from '@/business/campus-attendance/types';

export function toCampusAttendanceConfigViewModel(
  dto: CampusAttendanceConfigDto,
): CampusAttendanceConfigViewModel {
  return {
    id: dto.id,
    campus_id: dto.campus_key,
    attendance_link: dto.attendance_link,
    updated_by: dto.updated_by_label,
    updated_at: dto.updatedAt,
  };
}

export function toCampusAttendanceSummaryViewModel(
  dto: CampusAttendanceSummaryDto,
): CampusAttendanceSummaryViewModel {
  return {
    id: dto.id,
    campus_id: dto.campus_key,
    date: dto.date,
    total_enrolled: dto.total_enrolled,
    total_present: dto.total_present,
    total_absent: dto.total_absent,
    total_tardy: dto.total_tardy,
    attendance_percentage: dto.attendance_percentage,
    recorded_by: dto.recorded_by_label,
    notes: dto.notes,
  };
}

export function toCampusAttendanceSummaryMutationDto(
  input: CampusAttendanceEntryInput,
): CampusAttendanceSummaryMutationDto {
  return {
    total_enrolled: input.totalEnrolled,
    total_present: input.totalPresent,
    total_absent: input.totalAbsent,
    total_tardy: input.totalTardy,
    notes: input.notes,
  };
}
