Files
lumina/components/headerComponents/AvatarDropdown.tsx
mroxso b1de0f0118 Feature: NWC Implementation (#95)
* feat: add Alby JS SDK documentation and update package dependencies

* feat: add NostrWalletConnect component and ProfileSettingsNWCPage for wallet integration

* add NWC link to AvatarDropdown menu

* store and load nwc from localstorage

* feat: add NIP-47 documentation for Nostr Wallet Connect protocol

* feat: integrate Nostr Wallet Connect for zap payments and enhance UI feedback

* fix: update default custom amount to 21 and improve UI feedback for payment status on nwc

* fix: correct typo in QR code payment instruction text

---------

Co-authored-by: highperfocused <highperfocused@pm.me>
2025-04-25 22:11:01 +02:00

66 lines
1.8 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 asChild>
<Link href="/profile/settings/nwc">
NWC
</Link>
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => {
window.localStorage.clear();
window.location.href = "/";
}}>
Logout
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)
}