import { AxiosResponse } from "axios";
import performanceInstance from "@/shared/services/performanceInstance";
import { withHeaders } from "@/record-management/services/api/withHeaders";
import { CreateWorkingHoursDto } from "@/performance-management/types/workingHoursTypes";

export const createWorkingHours = async (
  data: CreateWorkingHoursDto
): Promise<AxiosResponse> => {
  return performanceInstance.post("/working-days", data, {
    headers: withHeaders(),
  });
};

export const getWorkingHours = async (id: string): Promise<AxiosResponse> => {
  return performanceInstance.get(`/working-days/${id}`, {
    headers: withHeaders(),
  });
};

export const getWorkingHoursList = async (): Promise<AxiosResponse> => {
  return performanceInstance.get("/working-days", {
    headers: withHeaders(),
  });
};

export const getWorkingHoursByPositionServiceId = async (
  positionServiceId: string
): Promise<AxiosResponse> => {
  return performanceInstance.get("/working-days", {
    headers: withHeaders(),
    params: {
      positionServiceId,
    },
  });
};

export const updateWorkingHours = async (
  id: string,
  data: CreateWorkingHoursDto
): Promise<AxiosResponse> => {
  return performanceInstance.put(`/working-days/${id}`, data, {
    headers: withHeaders(),
  });
};

export const deleteWorkingHours = async (
  id: string
): Promise<AxiosResponse> => {
  return performanceInstance.delete(`/working-days/${id}`, {
    headers: withHeaders(),
  });
};
