kgroad-frontend2/src/widgets/Navbar/NavAuth/NavAuth.tsx
Vladislav Khorev e0e2f5470d renamed folders
2024-02-14 08:04:02 +00:00

50 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;