import { Metadata } from "next";
import { Suspense } from "react";
import { I18nProvider, getServerI18n } from "@/i18n";
import { fetchProjects } from "@/app/api/projects";
import GenerateProjectPandLReport from "@/components/GenerateProjectPandLReport";
import { Typography } from "@mui/material";

export const metadata: Metadata = {
    title: "Project Cash Flow Report",
};

const ProjectPandLReport: React.FC = async () => {
    const { t } = await getServerI18n("reports");
    fetchProjects();

    return (
        <>
        <Typography variant="h4" marginInlineEnd={2}>
            {t("Project P&L Report")}
          </Typography>
            <I18nProvider namespaces={["report", "common"]}>
                <Suspense fallback={<GenerateProjectPandLReport.Loading />}>
                    <GenerateProjectPandLReport />
                </Suspense>
            </I18nProvider>
        </>
    );
};

export default ProjectPandLReport;
