"use server";

import { serverFetchJson, serverFetchWithNoContent } from "@/app/utils/fetchUtil";
import { BASE_API_URL } from "@/config/api";
import { Dayjs } from "dayjs";
import { cache } from "react";    

export interface CreateCompanyHolidayInputs {
    id: number;
    name: string;
    date: string;
}

export const saveCompanyHoliday = async (data: CreateCompanyHolidayInputs) => {
  return serverFetchJson(`${BASE_API_URL}/company-holidays/new`, {
    method: "POST",
    body: JSON.stringify(data),
    headers: { "Content-Type": "application/json" },
  });
};

export const deleteCompanyHoliday = async (id: number) => {
  const holiday = await serverFetchWithNoContent(
      `${BASE_API_URL}/company-holidays/${id}`,
      {
          method: "DELETE",
          headers: { "Content-Type": "application/json" },
      },
  );

  return holiday
};

