import { useTranslation } from "next-i18next";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import Layout from "../components/layout";
import { cookies as cookiesEs } from "../../public/locales/es/cookies";
import { cookies as cookiesEn } from "../../public/locales/en/cookies";

const CookiesPage = ({ currentCookies }) => {
  const { t: translate } = useTranslation();

  return (
    <Layout title={translate("footer.cookies", "Cookies Policy")}>
      <div className="layout py-10">
        <h2 className="font-inter font-bold text-2xl py-2">
          {translate("footer.cookies", "Cookies Policy")}
        </h2>
        <p className="whitespace-pre-line">{currentCookies}</p>
      </div>
    </Layout>
  );
};

export async function getStaticProps({ locale }) {
  const cookies = locale === "es" ? cookiesEs : cookiesEn;

  return {
    props: {
      currentCookies: cookies,
      ...(await serverSideTranslations(locale)),
    },
  };
}

export default CookiesPage;
