import { getServerI18n } from "@/i18n";
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import { Metadata } from "next";
import { Suspense } from "react";
import { I18nProvider } from "@/i18n";
import { fetchUserAbilities } from "@/app/utils/fetchUtil";
import { preloadMails } from "@/app/api/mail";
import MailSetting from "@/components/MailSetting";

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

const Customer: React.FC = async () => {
    const { t } = await getServerI18n("mail");
    preloadMails();
    const abilities = await fetchUserAbilities()

    return (
        <>
            <Stack
                direction="row"
                justifyContent="space-between"
                flexWrap="wrap"
                rowGap={2}
            >
                <Typography variant="h4" marginInlineEnd={2}>
                    {t("Mail")}
                </Typography>
            </Stack>
            <I18nProvider namespaces={["mail", "common"]}>
                <Suspense fallback={<MailSetting.Loading />}>
                    <MailSetting />
                </Suspense>
            </I18nProvider>
        </>
    );
};

export default Customer;