mirror of
https://github.com/lumina-rocks/lumina.git
synced 2026-04-08 22:46:49 +02:00
feat: add Relays link to AvatarDropdown menu feat: create Badge component for status indicators fix: update @radix-ui/react-slot version in package.json and package-lock.json Co-authored-by: highperfocused <highperfocused@pm.me>
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import { MoonIcon, SunIcon } from "@radix-ui/react-icons"
|
|
import { useTheme } from "next-themes"
|
|
|
|
import { Button } from "@/components/ui/button"
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu"
|
|
import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"
|
|
import { useProfile } from "nostr-react"
|
|
import Link from "next/link"
|
|
import { nip19 } from "nostr-tools"
|
|
|
|
export function AvatarDropdown() {
|
|
let pubkey = window.localStorage.getItem('pubkey');
|
|
let pubkeyEncoded = pubkey ? nip19.npubEncode(pubkey) : pubkey;
|
|
let src = "https://robohash.org/" + (pubkey as string);
|
|
const { data: userData } = useProfile({
|
|
pubkey: pubkey as string,
|
|
});
|
|
if (pubkey !== null) {
|
|
src = userData?.picture || "https://robohash.org/" + pubkey;
|
|
}
|
|
return (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Avatar>
|
|
<AvatarImage src={src} />
|
|
</Avatar>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end">
|
|
<DropdownMenuItem asChild>
|
|
<Link href={`/profile/${pubkeyEncoded}`}>
|
|
Profile
|
|
</Link>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem asChild>
|
|
<Link href="/relays">
|
|
Relays
|
|
</Link>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem asChild>
|
|
<Link href="/profile/settings">
|
|
Settings
|
|
</Link>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem onSelect={() => {
|
|
window.localStorage.clear();
|
|
window.location.href = "/";
|
|
}}>
|
|
Logout
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)
|
|
} |