import { TypeEnum } from "@/app/utils/typeEnum";
import MaterialSearch from "@/components/ItemsSearch";
import { getServerI18n } from "@/i18n";
import Add from "@mui/icons-material/Add";
import Button from "@mui/material/Button";
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import { Metadata } from "next";
import Link from "next/link";
import { Suspense } from "react";

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

const materialSetting: React.FC = async () => {
  const byProduct = TypeEnum.BYPRODUCT
  const { t } = await getServerI18n(byProduct);
  //   preloadClaims();

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

export default materialSetting;
