import { usePrimaryPage } from '@/PageManager'
import { useKeyboardNavigation } from '@/providers/KeyboardNavigationProvider'
import { useNostr } from '@/providers/NostrProvider'
import { UserRound } from 'lucide-react'
import SidebarItem from './SidebarItem'

export default function ProfileButton({ collapse, navIndex }: { collapse: boolean; navIndex?: number }) {
  const { navigate, current, display } = usePrimaryPage()
  const { checkLogin } = useNostr()
  const { clearColumn } = useKeyboardNavigation()

  const handleClick = () => {
    checkLogin(() => {
      navigate('profile')
      clearColumn(1)
    })
  }

  return (
    <SidebarItem
      title="Profile"
      onClick={handleClick}
      active={display && current === 'profile'}
      collapse={collapse}
      navIndex={navIndex}
    >
      <UserRound />
    </SidebarItem>
  )
}
