import { Metadata } from "next";
import { getServerI18n, I18nProvider } from "@/i18n";
import Typography from "@mui/material/Typography";
import { Button, Link, Stack } from "@mui/material";
import { Add } from "@mui/icons-material";
import { Suspense } from "react";
import { preloadQcItem } from "@/app/api/settings/qcItem";
import QcItemSearch from "@/components/QcItemSearch";

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

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

  preloadQcItem();

  return (
    <>
      <Stack
        direction="row"
        justifyContent="space-between"
        flexWrap="wrap"
        rowGap={2}
      >
        <Typography variant="h4" marginInlineEnd={2}>
          {t("Qc Item")}
        </Typography>
        <Button
          variant="contained"
          startIcon={<Add />}
          LinkComponent={Link}
          href="qcItem/create"
        >
          {t("Create Qc Item")}
        </Button>
      </Stack>
      <Suspense fallback={<QcItemSearch.Loading />}>
        <QcItemSearch />
      </Suspense>
    </>
  );
};

export default qcItem;
