import apiClient from "@/infrastructure/apiClient";
import { attendance } from "@/infrastructure/apiPaths/hrPath";

const attendanceService = {
  async search(searchModel) {
    return await apiClient
      .post(attendance.search, searchModel)
      .then((r) => r.data);
  },

  async getMonthlySummary(month, year) {
    try {
      const response = await apiClient.get(attendance.getMonthlySummary, {
        params: { month, year }
      });
      return response.data;
    } catch (error) {
      console.error('Error fetching monthly summary:', error);
      throw error;
    }
  },

  async getUserAttendanceDetail(month, year, userId) {
    try {
      const response = await apiClient.get(attendance.getUserAttendanceDetail, {
        params: { month, year, userId }
      });
      return response.data;
    } catch (error) {
      console.error('Error fetching user attendance detail:', error);
      throw error;
    }
  },
};

export default attendanceService;
