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

export interface SkillResult {
    action: unknown;
    id: number;
    name: string;
    description: string;
    code: string;
    delete: unknown
  }

  export const preloadSkill = () => {
    fetchSkill();
  };

  export const fetchSkill = cache(async () => {
    return serverFetchJson<SkillResult[]>(`${BASE_API_URL}/skill`, {
      next: { tags: ["skill"] },
    });
  });

  export const fetchSkillDetail = cache(async (id: number) => {
    return serverFetchJson<SkillResult[]>(`${BASE_API_URL}/skill/${id}`, {
      next: { tags: ["skill"] },
    });
  });