import { fetchAllCustomers, fetchAllSubsidiaries } from "@/app/api/customer";
import { fetchGrades } from "@/app/api/grades";
import {
  fetchProjectBuildingTypes,
  fetchProjectCategories,
  fetchProjectContractTypes,
  fetchProjectFundingTypes,
  fetchProjectLocationTypes,
  fetchProjectServiceTypes,
  fetchProjectWorkNatures,
} from "@/app/api/projects";
import { preloadStaff, preloadTeamLeads } from "@/app/api/staff";
import { fetchAllTasks, fetchTaskTemplates } from "@/app/api/tasks";
import CreateProject from "@/components/CreateProject";
import { I18nProvider, getServerI18n } from "@/i18n";
import Typography from "@mui/material/Typography";
import { Metadata } from "next";

export const metadata: Metadata = {
  title: "Create Project",
};

const Projects: React.FC = async () => {
  const { t } = await getServerI18n("projects");

  // Preload necessary dependencies
  fetchAllTasks();
  fetchTaskTemplates();
  fetchProjectCategories();
  fetchProjectContractTypes();
  fetchProjectFundingTypes();
  fetchProjectLocationTypes();
  fetchProjectServiceTypes();
  fetchProjectBuildingTypes();
  fetchProjectWorkNatures();
  fetchAllCustomers();
  fetchAllSubsidiaries();
  fetchGrades();
  preloadTeamLeads();
  preloadStaff();

  return (
    <>
      <Typography variant="h4">{t("Create Project")}</Typography>
      <I18nProvider namespaces={["projects"]}>
        <CreateProject />
      </I18nProvider>
    </>
  );
};

export default Projects;
