mirror of
https://github.com/dergigi/boris.git
synced 2025-12-19 23:54:23 +01:00
- Create UserHeader component to display user info and logout button - Move 'Logged in as: user' from sidebar to app-header in top-right - Remove user info display from BookmarkList and Bookmarks components - Simplify bookmarks-header layout (only contains collapse button now) - Update CSS to display user info and logout button inline with proper spacing
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import React from 'react'
|
|
import { Hooks } from 'applesauce-react'
|
|
import { useEventModel } from 'applesauce-react/hooks'
|
|
import { Models } from 'applesauce-core'
|
|
import { faRightFromBracket } from '@fortawesome/free-solid-svg-icons'
|
|
import IconButton from './IconButton'
|
|
|
|
interface UserHeaderProps {
|
|
onLogout: () => void
|
|
}
|
|
|
|
const UserHeader: React.FC<UserHeaderProps> = ({ onLogout }) => {
|
|
const activeAccount = Hooks.useActiveAccount()
|
|
const profile = useEventModel(Models.ProfileModel, activeAccount ? [activeAccount.pubkey] : null)
|
|
|
|
const formatUserDisplay = () => {
|
|
if (!activeAccount) return 'Unknown User'
|
|
|
|
if (profile?.name) {
|
|
return profile.name
|
|
}
|
|
if (profile?.display_name) {
|
|
return profile.display_name
|
|
}
|
|
if (profile?.nip05) {
|
|
return profile.nip05
|
|
}
|
|
|
|
return `${activeAccount.pubkey.slice(0, 8)}...${activeAccount.pubkey.slice(-8)}`
|
|
}
|
|
|
|
return (
|
|
<div className="app-header">
|
|
<p className="user-info">Logged in as: {formatUserDisplay()}</p>
|
|
<IconButton
|
|
icon={faRightFromBracket}
|
|
onClick={onLogout}
|
|
title="Logout"
|
|
ariaLabel="Logout"
|
|
variant="ghost"
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default UserHeader
|
|
|