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

export interface SalaryResult {
  id: number;
  lowerLimit: string;
  upperLimit: string;
  salaryPoint: number;
  salary: number;
  hourlyRate: string;
}

export const preloadSalarys = () => {
  fetchSalarys();
};

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