mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 16:33:36 +00:00
put lightning address in balance card
This commit is contained in:
1 parent
c8ad3b1a36
commit
dd3f4465c5
2 files changed
+57
-46
No files matched your search
@@ -2,8 +2,9 @@ import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog';
|
||||
import { Wallet, ChevronDown, Plus, X, Zap, Coins, HelpCircle } from 'lucide-react';
|
||||
import { Wallet, ChevronDown, Plus, X, Zap, Coins, HelpCircle, QrCode, Copy, Check } from 'lucide-react';
|
||||
import { useCashuBalances } from '@/hooks/cashu/useCashuBalances';
|
||||
import { useState } from 'react';
|
||||
|
||||
interface CashuMint {
|
||||
url: string;
|
||||
@@ -26,6 +27,12 @@ interface BalanceDisplayProps {
|
||||
onRemoveMint: (mint: CashuMint) => void;
|
||||
onShowDenominations: (mintUrl: string) => void;
|
||||
getCleanMintLabel: (mint: { name?: string; url: string }) => string;
|
||||
// Lightning address props
|
||||
userPubkey?: string;
|
||||
npubCashUsername?: string;
|
||||
onCopyToClipboard: (text: string) => Promise<void>;
|
||||
onShowLightningAddressQR: (qrCode: string) => void;
|
||||
generateQRCode: (text: string) => Promise<string>;
|
||||
}
|
||||
|
||||
export function BalanceDisplay({
|
||||
@@ -44,8 +51,14 @@ export function BalanceDisplay({
|
||||
onRemoveMint,
|
||||
onShowDenominations,
|
||||
getCleanMintLabel,
|
||||
userPubkey,
|
||||
npubCashUsername,
|
||||
onCopyToClipboard,
|
||||
onShowLightningAddressQR,
|
||||
generateQRCode,
|
||||
}: BalanceDisplayProps) {
|
||||
const { convertCurrency } = useCashuBalances(null);
|
||||
const [lightningAddressCopied, setLightningAddressCopied] = useState(false);
|
||||
|
||||
return (
|
||||
<div className="text-center py-2">
|
||||
@@ -187,6 +200,41 @@ export function BalanceDisplay({
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Lightning Address */}
|
||||
{userPubkey && (
|
||||
<div className="mt-3 flex items-center justify-center gap-2">
|
||||
<button
|
||||
onClick={async () => {
|
||||
const lightningAddress = `${npubCashUsername}@npubx.cash`;
|
||||
await onCopyToClipboard(lightningAddress);
|
||||
setLightningAddressCopied(true);
|
||||
setTimeout(() => setLightningAddressCopied(false), 2000);
|
||||
}}
|
||||
className="flex items-center gap-2 px-3 py-1.5 bg-muted hover:bg-muted/80 rounded-md border text-sm font-mono transition-colors h-[34px]"
|
||||
title="Click to copy Lightning address"
|
||||
>
|
||||
<span className="truncate max-w-[250px] sm:max-w-none">
|
||||
{npubCashUsername}@npubx.cash
|
||||
</span>
|
||||
{lightningAddressCopied ? (
|
||||
<Check className="h-4 w-4 text-green-600 flex-shrink-0" />
|
||||
) : (
|
||||
<Copy className="h-4 w-4 text-muted-foreground flex-shrink-0" />
|
||||
)}
|
||||
</button>
|
||||
<button
|
||||
onClick={async () => {
|
||||
const lightningAddress = `${npubCashUsername}@npubx.cash`;
|
||||
const qr = await generateQRCode(lightningAddress);
|
||||
onShowLightningAddressQR(qr);
|
||||
}}
|
||||
className="flex items-center justify-center px-2 py-1.5 hover:bg-muted rounded-md transition-colors h-[34px]"
|
||||
title="Show QR Code"
|
||||
>
|
||||
<QrCode className="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user