import SalarySearch from "@/components/SalarySearch";
import { Metadata } from "next";
import { I18nProvider, 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 Link from "next/link";
import { Suspense } from "react";
import { fetchSalarys, preloadSalarys } from "@/app/api/salarys";

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

const Salary: React.FC = async () => {
  const { t } = await getServerI18n("Salary");
  // Preload necessary dependencies
  // fetchSalarys();
  // preloadSalarys();
  
  return (
    <>
      <Stack
        direction="row"
        justifyContent="space-between"
        flexWrap="wrap"
        rowGap={2}
      >
        <Typography variant="h4" marginInlineEnd={2}>
          {t("Salary")}
        </Typography>
        {/* <Button
          variant="contained"
          startIcon={<Add />}
          LinkComponent={Link}
          href="/settings/position/new"
        >
          {t("Create Salary")}
        </Button> */}
      </Stack>
      <I18nProvider namespaces={["salarys"]}>
        <Suspense fallback={<SalarySearch.Loading />}>
          <SalarySearch/>
        </Suspense>
      </I18nProvider>
    </>
  )
};

export default Salary;
