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

export interface PositionResult {
  id: number;
  code: string;
  name: string;
  description: string;
}

export const preloadPositions = () => {
  fetchPositions();
};

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