//src\app\api\report\index.ts
import { serverFetchJson } from "@/app/utils/fetchUtil";
import { BASE_API_URL } from "@/config/api";
import { cache } from "react";

export interface FinancialStatus {
  id: number;
  projectCode: string;
  projectName: string;
  team: string;
  teamLeader: string;
  startDate: string;
  startDateFrom: string;
  startDateTo: string;
  targetEndDate: string;
  client: string;
  subsidiary: string;
  status: string;
}

export interface TeamCombo {
  id: number;
  name: string;
  code: string;
  targetDate: string;
  targetDateFrom: string;
  targetDateTo: string;
}

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

export const fetchProjectsFinancialStatus = cache(async () => {
  return mockProjects;
});

export const fetchTeamCombo = cache(async () => {
  return serverFetchJson<TeamCombo[]>(`${BASE_API_URL}/team/combo2`, {
    next: { tags: ["teamCombo"] },
  });
});

const mockProjects: FinancialStatus[] = [
  {
    id: 1,
    projectCode: "CUST-001",
    projectName: "Client A",
    team: "N/A",
    teamLeader: "N/A",
    startDate: "5",
    startDateFrom: "5",
    startDateTo: "5",
    targetEndDate: "s",
    client: "ss",
    subsidiary: "ss",
    status: "1",
  },
];
