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 Add from "@mui/icons-material/Add";
import WarehouseTabs from "@/components/Warehouse/WarehouseTabs";
import WarehouseHandleWrapper from "@/components/WarehouseHandle/WarehouseHandleWrapper";
import TabStockTakeSectionMapping from "@/components/Warehouse/TabStockTakeSectionMapping";

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

const Warehouse: React.FC = async () => {
  const { t } = await getServerI18n("warehouse");
  return (
    <>
      <Stack direction="row" justifyContent="space-between" flexWrap="wrap" rowGap={2}>
        <Typography variant="h4" marginInlineEnd={2}>
          {t("Warehouse")}
        </Typography>
        <Button
          variant="contained"
          startIcon={<Add />}
          LinkComponent={Link}
          href="/settings/warehouse/create"
        >
          {t("Create Warehouse")}
        </Button>
      </Stack>
      <I18nProvider namespaces={["warehouse","navigation","common","dashboard"]}>
        <Suspense fallback={null}>
          <WarehouseTabs
            tab0Content={<WarehouseHandleWrapper />}
            tab1Content={<TabStockTakeSectionMapping />}
          />
        </Suspense>
      </I18nProvider>
    </>
  );
};
export default Warehouse;