import ProductionProcessPage from "../../../components/ProductionProcess/ProductionProcessPage";
import ProductionProcessLoading from "../../../components/ProductionProcess/ProductionProcessLoading";
import { I18nProvider, getServerI18n } from "../../../i18n";

import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import { Metadata } from "next";
import { Suspense } from "react";
import { fetchPrinterCombo } from "@/app/api/settings/printer";

export const metadata: Metadata = {
  title: "Job Order Production Process",
};

const productionProcess: React.FC = async () => {
  const { t } = await getServerI18n("productionProcess", "navigation", "common");
  const printerCombo = await fetchPrinterCombo();
  return (
    <>
      <Stack
        direction="row"
        justifyContent="space-between"
        flexWrap="wrap"
        rowGap={2}
      >
        <Typography variant="h4" marginInlineEnd={2}>
          {t("Job Order Production Process")}
        </Typography>
        {/* Optional: Remove or modify create button, because creation is done via API automatically */}
        {/* <Button
          variant="contained"
          startIcon={<Add />}
          LinkComponent={Link}
          href="/productionProcess/create"
        >
          {t("Create Process")}
        </Button> */}
      </Stack>
      <I18nProvider namespaces={["productionProcess","navigation","common","purchaseOrder","jo","dashboard"]}>
        <Suspense fallback={<ProductionProcessLoading />}>
          <ProductionProcessPage printerCombo={printerCombo} />
        </Suspense>
      </I18nProvider>
    </>
  );
};

export default productionProcess;