"use client"

import { usePathname } from "next/navigation"
import { useIntl } from "react-intl"

import { login } from "@/constants/routes/handleAuth"

import Link from "@/components/TempDesignSystem/Link"

import { LangParams } from "@/types/params"

export default function LoginButton({
  className,
  lang,
}: LangParams & { className: string }) {
  const { formatMessage } = useIntl()
  const pathName = usePathname()

  return (
    <Link
      href={`${login[lang]}?redirectTo=${encodeURIComponent(`/${lang}${pathName}`)}`}
      className={className}
    >
      {formatMessage({ id: "Log in" })}
    </Link>
  )
}
