import { useAppSelector } from 'hooks' import { nip19 } from 'nostr-tools' import { useState } from 'react' import { NavLink, NavLinkProps } from 'react-router-dom' import { appRoutes, getProfilePageRoute } from 'routes' import 'styles/socialNav.css' import { npubToHex } from 'utils' export const SocialNav = () => { const [isCollapsed, setIsCollapsed] = useState(false) const userState = useAppSelector((state) => state.user) let profileRoute = '' if (userState.auth && userState.user) { // Redirect to user's profile is no profile is linked const userHexKey = npubToHex(userState.user.npub as string) if (userHexKey) { profileRoute = getProfilePageRoute( nip19.nprofileEncode({ pubkey: userHexKey }) ) } } const toggleNav = () => { setIsCollapsed(!isCollapsed) } return (
{!isCollapsed && (
{!!userState.auth && ( )}
)}
) } interface NavButtonProps extends NavLinkProps { svgPath: string viewBox?: string } const NavButton = ({ svgPath, viewBox = '0 0 512 512', ...rest }: NavButtonProps) => ( `btn btnMain socialNavInsideBtn ${ isActive ? 'socialNavInsideBtnActive' : '' }` } > )