import { serverFetchJson } from "@/app/utils/fetchUtil";
import { BASE_API_URL } from "@/config/api";
import { cache } from "react";
import "server-only";
import EventInput from '@fullcalendar/react';

export interface HolidaysList extends EventInput  {
    id: string;
    title: string;
    date: string;
    extendedProps: {
        calendar: string;
    };
}

export interface HolidaysResult {
    id: string;
    name: string;
    date: number[];
}

export const preloadCompanys = () => {
    fetchHolidays();
};

export const fetchHolidays = cache(async () => {
    return serverFetchJson<HolidaysResult[]>(`${BASE_API_URL}/company-holidays`, {
      next: { tags: ["company-holidays"] },
    });
});