import { Metadata } from "next";
import { getServerI18n, I18nProvider } from "@/i18n";
import Typography from "@mui/material/Typography";
import { Suspense } from "react";
import { Stack } from "@mui/material";
import { Button } from "@mui/material";
import Link from "next/link";
import PrinterSearch from "@/components/PrinterSearch";
import Add from "@mui/icons-material/Add";

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

const Printer: React.FC = async () => {
  const { t } = await getServerI18n("printer");
  
  return (
    <>
      <Stack
        direction="row"
        justifyContent="space-between"
        flexWrap="wrap"
        rowGap={2}
      >
        <Typography variant="h4" marginInlineEnd={2}>
          {t("Printer")}
        </Typography>
        <Button
          variant="contained"
          startIcon={<Add />}
          LinkComponent={Link}
          href="/settings/printer/create"
        >
          {t("Create Printer") || "新增列印機"}
        </Button>
      </Stack>
      <I18nProvider namespaces={["printer","navigation","common","dashboard"]}>
        <Suspense fallback={<PrinterSearch.Loading />}>
          <PrinterSearch />
        </Suspense>
      </I18nProvider>
    </>
  );
};

export default Printer;
