import "./NavAuth.scss";
import { usePathname } from "next/navigation";
import { useSession } from "next-auth/react";
import { Link } from "@/shared/config/navigation";
import { useTranslations } from "next-intl";

interface INavAuthProps {
  responsible?: boolean;
  setOpenMenu: (boolean: boolean) => void;
}

const NavAuth: React.FC<INavAuthProps> = ({
  responsible,
  setOpenMenu,
}: INavAuthProps) => {
  const t = useTranslations("navigation");
  const session = useSession();

  const auth = session.status === "authenticated" ? true : false;

  const pathname = usePathname();
  return (
    <>
      {auth ? (
        <Link
          onClick={() => setOpenMenu(false)}
          href="/profile/personal"
          className={`nav-auth-profile-${
            responsible
              ? `sm${pathname === "/profile" ? "_active" : ""}`
              : "lg"
          }`}
        >
          {t("profile")}
        </Link>
      ) : (
        <Link
          onClick={() => setOpenMenu(false)}
          href="/sign-in"
          className={`nav-auth-signin-${
            responsible
              ? `sm${pathname === "/sign-in" ? "_active" : ""}`
              : "lg"
          }`}
        >
          {t("login")}
        </Link>
      )}
    </>
  );
};

export default NavAuth;
