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

const GlobalRepository = {
  getDashboardProgressionData: ({ days = '', FromDate = '', projectId = '' }) => {
    let params;
    if(projectId == null){
      params = new URLSearchParams({
        days: days.toString(),
        FromDate,
      });
    }else{
      params = new URLSearchParams({
        days: days.toString(),
        FromDate,
        projectId,
      });
    }

    return api.get(`/api/Dashboard/Progression?${params.toString()}`);
  },

  getDashboardAttendanceData: ( date,projectId ) => {  

  return api.get(`/api/Dashboard/project-attendance/${projectId}?date=${date}`);
},
  getDashboardProjectsCardData: () => {
    return api.get(`/api/Dashboard/projects`);
  },
  
  getDashboardTeamsCardData: (projectId) => {
  const url = projectId
    ? `/api/Dashboard/teams?projectId=${projectId}`
    : `/api/Dashboard/teams`;
  return api.get(url);
},

  getDashboardTasksCardData: (projectId) => {
  const url = projectId
    ? `/api/Dashboard/tasks?projectId=${projectId}`
    : `/api/Dashboard/tasks`;
  return api.get(url);
},

 getAttendanceOverview:(projectId,days)=>api.get(`/api/dashboard/attendance-overview/${projectId}?days=${days}`)

};

export default GlobalRepository;
