import { api } from "../utils/axiosClient";


const AttendanceRepository =  {
  markAttendance:(data)=>api.post("/api/attendance/record",data),
  getAttendance:(id)=>api.get(`api/attendance/project/team?projectId=${id}`),
  getAttendanceFilteredByDate: ( projectId, fromDate, toDate ) =>
  {
    
    let url = `api/Attendance/project/log?projectId=${ projectId }`
    if (fromDate) {
      url += `&dateFrom=${fromDate}`;
    }

    if (toDate) {
      url += `&dateTo=${toDate}`;
    }
    return api.get(url)
  },
  
  getAttendanceLogs: ( id ) => api.get( `api/attendance/log/attendance/${ id }` ),
  getRegularizeList: ( id ) => api.get( `api/attendance/regularize?projectId=${ id }` ),
  
  getAttendanceByEmployee: ( employeeId, fromDate, toDate ) =>
    {
      
      let url = `api/Attendance/log/employee/${ employeeId }?`
      if (fromDate) {
        url += `&dateFrom=${fromDate}`;
      }
  
      if (toDate) {
        url += `&dateTo=${toDate}`;
      }
      return api.get(url)
    },

}

export default AttendanceRepository;

