//src\components\LateStartReportGen\LateStartReportGenWrapper.tsx
import { fetchProjectsFinancialStatus, fetchTeamCombo } from "@/app/api/reporte1";
import React from "react";
import FinancialStatusReportGen from "./FinancialStatusReportGen";
import FinancialStatusReportGenLoading from "./FinancialStatusReportGenLoading";
import { fetchUserStaff } from "@/app/utils/fetchUtil";

interface SubComponents {
  Loading: typeof FinancialStatusReportGenLoading;
}

const FinancialStatusReportGenWrapper: React.FC & SubComponents = async () => {
  const clentprojects = await fetchProjectsFinancialStatus();

  const [teamCombo, userStaff] = await Promise.all([fetchTeamCombo(), fetchUserStaff()])

  return <FinancialStatusReportGen projects={clentprojects} userStaff={userStaff} teamCombo={!Boolean(userStaff?.isTeamLead) ? teamCombo : teamCombo.filter(team => team.id === userStaff?.teamId)}/>;
};

FinancialStatusReportGenWrapper.Loading = FinancialStatusReportGenLoading;

export default FinancialStatusReportGenWrapper;