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


export interface ClientProjectResult {
  id: number;
  customerId: number;
  customerCode: string;
  customerName: string;
  subsidiaryId: number;
  subsidiaryCode: string;
  subsidiaryName: string;
  projectNo: number;
}

export const preloadClientProjects = () => {
  fetchAllClientProjects();
};

export const fetchAllClientProjects = cache(async () => {
  return serverFetchJson<ClientProjectResult[]>(`${BASE_API_URL}/dashboard/searchCustomerSubsidiary`);
});
