diff --git a/src/layout/socialNav.tsx b/src/layout/socialNav.tsx index cdc142c..b218b6e 100644 --- a/src/layout/socialNav.tsx +++ b/src/layout/socialNav.tsx @@ -1,13 +1,28 @@ 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) } @@ -42,7 +57,7 @@ export const SocialNav = () => { /> {!!userState.auth && ( )}