import React from "react";
import { fetchAllCustomers } from "@/app/api/customer";
import { fetchTeam } from "@/app/api/team";
import ProjectCompletionReportLoading from "./ProjectCompletionReportLoading";
import ProjectCompletionReport from "./ProjectCompletionReport";
import { getServerSession } from "next-auth";
import { authOptions } from "@/config/authConfig";
import { TEAM_LEAD } from "@/middleware";

interface SubComponents {
  Loading: typeof ProjectCompletionReportLoading;
}

const ProjectCompletionReportWrapper: React.FC & SubComponents = async () => {
  const session: any = await getServerSession(authOptions)
  const teamId = session.staff?.teamId
  const role = session.role

  return <ProjectCompletionReport teamId={role.includes(TEAM_LEAD) && session.staff?.team ? teamId : null}/>
};

ProjectCompletionReportWrapper.Loading = ProjectCompletionReportLoading;

export default ProjectCompletionReportWrapper;