ProfileButton.tsx raw

   1  import { useSecondaryPage } from '@/PageManager'
   2  import { toProfile } from '@/lib/link'
   3  import { useNostr } from '@/providers/NostrProvider'
   4  import { UserRound } from 'lucide-react'
   5  import SidebarItem from './SidebarItem'
   6  
   7  export default function ProfileButton({ collapse, navIndex }: { collapse: boolean; navIndex?: number }) {
   8    const { push } = useSecondaryPage()
   9    const { pubkey, checkLogin } = useNostr()
  10  
  11    const handleClick = () => {
  12      checkLogin(() => {
  13        if (pubkey) {
  14          push(toProfile(pubkey))
  15        }
  16      })
  17    }
  18  
  19    return (
  20      <SidebarItem
  21        title="Profile"
  22        onClick={handleClick}
  23        active={false}
  24        collapse={collapse}
  25        navIndex={navIndex}
  26      >
  27        <UserRound />
  28      </SidebarItem>
  29    )
  30  }
  31