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


export interface FinancialSummaryCardResult {
  teamId: number;
  teamName: string;
  projectNo: number;
  totalFee: number;
  totalBudget: number;
  cumulativeExpenditure: number;
  totalInvoiced: number;
  totalReceived: number;
  cashFlowStatus: string;
  cpi: number;
}

export const preloadFinancialSummaryCard = () => {
  fetchFinancialSummaryCard();
};

export const fetchFinancialSummaryCard = cache(async () => {
  return serverFetchJson<FinancialSummaryCardResult[]>(`${BASE_API_URL}/dashboard/searchFinancialSummaryCard`);
});
