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

export interface ResourceSummaryResult {
  id: number;
  projectCode: string;
  projectName: string;
  customerCode: string;
  customerName: string;
  customerCodeAndName: string;
  subsidiaryCodeAndName: string;
}

export const preloadProjects = () => {
  fetchResourceSummary();
};

export const fetchResourceSummary = cache(async () => {
  return serverFetchJson<ResourceSummaryResult[]>(`${BASE_API_URL}/dashboard/searchProjectResourcesSummary`);
});

