//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 { getUserStaff } from "@/app/utils/commonUtil";

interface SubComponents {
  Loading: typeof FinancialStatusReportGenLoading;
}

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

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

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

FinancialStatusReportGenWrapper.Loading = FinancialStatusReportGenLoading;

export default FinancialStatusReportGenWrapper;