import Link from "next/link";
import "./NavAuth.scss";
import { usePathname } from "next/navigation";
import { useSession } from "next-auth/react";

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

const NavAuth: React.FC<INavAuthProps> = ({
  responsible,
  setOpenMenu,
}: INavAuthProps) => {
  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"
          }`}
        >
          Профиль
        </Link>
      ) : (
        <Link
          onClick={() => setOpenMenu(false)}
          href="/sign-in"
          className={`nav-auth-signin-${
            responsible
              ? `sm${pathname === "/sign-in" ? "_active" : ""}`
              : "lg"
          }`}
        >
          Войти
        </Link>
      )}
    </>
  );
};

export default NavAuth;
