import { baseApiRequest } from "../apiRequests/baseApiRequest";
import { WorkingDaysResponse } from "./type";

const PROJECT_MANAGEMENT_BASE_URL = `${process.env.NEXT_PUBLIC_PROJECT_MANAGEMENT_API_URL}/api/v1`;

export const getAllWorkingDays = async (): Promise<WorkingDaysResponse> => {
  return await baseApiRequest(
    `${PROJECT_MANAGEMENT_BASE_URL}/working-days`,
    {
      method: "GET",
      headers: { "Content-Type": "application/json" },
      credentials: "include",
    },
    {
      isAccessTokenRequird: true,
      revalidatePaths: ["/working-days"],
    },
  );
};

export const getWorkingDaysByYear = async (
  year: string,
): Promise<WorkingDaysResponse> => {
  return await baseApiRequest(
    `${PROJECT_MANAGEMENT_BASE_URL}/working-days/year/${year}`,
    {
      method: "GET",
      headers: {
        "Content-Type": "application/json",
      },
      credentials: "include",
    },
    {
      isAccessTokenRequird: true,
      revalidatePaths: [`/working-days/year/${year}`],
    },
  );
};