import { fetchAllTasks, fetchTaskTemplates } from "@/app/api/tasks";
import CreateProject from "./CreateProject";
import {
  fetchProjectBuildingTypes,
  fetchProjectCategories,
  fetchProjectContractTypes,
  fetchProjectFundingTypes,
  fetchProjectLocationTypes,
  fetchProjectServiceTypes,
  fetchProjectWorkNatures,
} from "@/app/api/projects";
import { fetchStaff, fetchTeamLeads } from "@/app/api/staff";
import { fetchAllCustomers, fetchAllSubsidiaries } from "@/app/api/customer";

const CreateProjectWrapper: React.FC = async () => {
  const [
    tasks,
    taskTemplates,
    projectCategories,
    teamLeads,
    allCustomers,
    allSubsidiaries,
    contractTypes,
    fundingTypes,
    locationTypes,
    serviceTypes,
    buildingTypes,
    workNatures,
    allStaffs,
  ] = await Promise.all([
    fetchAllTasks(),
    fetchTaskTemplates(),
    fetchProjectCategories(),
    fetchTeamLeads(),
    fetchAllCustomers(),
    fetchAllSubsidiaries(),
    fetchProjectContractTypes(),
    fetchProjectFundingTypes(),
    fetchProjectLocationTypes(),
    fetchProjectServiceTypes(),
    fetchProjectBuildingTypes(),
    fetchProjectWorkNatures(),
    fetchStaff(),
  ]);

  return (
    <CreateProject
      allTasks={tasks}
      projectCategories={projectCategories}
      taskTemplates={taskTemplates}
      teamLeads={teamLeads}
      allSubsidiaries={allSubsidiaries}
      allCustomers={allCustomers}
      contractTypes={contractTypes}
      fundingTypes={fundingTypes}
      locationTypes={locationTypes}
      serviceTypes={serviceTypes}
      buildingTypes={buildingTypes}
      workNatures={workNatures}
      allStaffs={allStaffs}
      // Mocks
      grades={[
        { name: "Grade 1", id: 1, code: "1" },
        { name: "Grade 2", id: 2, code: "2" },
        { name: "Grade 3", id: 3, code: "3" },
        { name: "Grade 4", id: 4, code: "4" },
        { name: "Grade 5", id: 5, code: "5" },
      ]}
    />
  );
};

export default CreateProjectWrapper;
