mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-06 08:47:23 +00:00
put lightning address in balance card
This commit is contained in:
1 parent
c8ad3b1a36
commit
dd3f4465c5
2 files changed
+55
-44
No files matched your search
@@ -17,7 +17,6 @@ import { TransactionHistory } from '@/components/wallet/TransactionHistory';
|
|||||||
import { ProofBreakdownModal } from '@/components/wallet/ProofBreakdownModal';
|
import { ProofBreakdownModal } from '@/components/wallet/ProofBreakdownModal';
|
||||||
import { RemoveMintModal } from '@/components/wallet/RemoveMintModal';
|
import { RemoveMintModal } from '@/components/wallet/RemoveMintModal';
|
||||||
import { LoginArea } from '@/components/auth/LoginArea';
|
import { LoginArea } from '@/components/auth/LoginArea';
|
||||||
import { QrCode, Copy, Check } from 'lucide-react';
|
|
||||||
|
|
||||||
export function CashuWallet() {
|
export function CashuWallet() {
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -105,7 +104,6 @@ export function CashuWallet() {
|
|||||||
const [lightningQRCode, setLightningQRCode] = useState<string>('');
|
const [lightningQRCode, setLightningQRCode] = useState<string>('');
|
||||||
const [showLightningAddressQR, setShowLightningAddressQR] = useState(false);
|
const [showLightningAddressQR, setShowLightningAddressQR] = useState(false);
|
||||||
const [lightningAddressQRCode, setLightningAddressQRCode] = useState<string>('');
|
const [lightningAddressQRCode, setLightningAddressQRCode] = useState<string>('');
|
||||||
const [lightningAddressCopied, setLightningAddressCopied] = useState(false);
|
|
||||||
const [npubCashUserInfo, setNpubCashUserInfo] = useState<NpubCashUserInfo | null>(null);
|
const [npubCashUserInfo, setNpubCashUserInfo] = useState<NpubCashUserInfo | null>(null);
|
||||||
|
|
||||||
const [showInvoiceModal, setShowInvoiceModal] = useState(false);
|
const [showInvoiceModal, setShowInvoiceModal] = useState(false);
|
||||||
@@ -731,50 +729,15 @@ export function CashuWallet() {
|
|||||||
onRemoveMint={handleRemoveMintClick}
|
onRemoveMint={handleRemoveMintClick}
|
||||||
onShowDenominations={handleShowDenominations}
|
onShowDenominations={handleShowDenominations}
|
||||||
getCleanMintLabel={getCleanMintLabel}
|
getCleanMintLabel={getCleanMintLabel}
|
||||||
/>
|
userPubkey={user?.pubkey}
|
||||||
|
npubCashUsername={user?.pubkey ? (npubCashUserInfo?.name || nip19.npubEncode(user.pubkey)) : undefined}
|
||||||
{/* ========================================================================
|
onCopyToClipboard={copyToClipboard}
|
||||||
SECTION: Lightning Address
|
onShowLightningAddressQR={(qr) => {
|
||||||
======================================================================== */}
|
|
||||||
{user?.pubkey && (() => {
|
|
||||||
// Use username if available, otherwise use npub
|
|
||||||
const identifier = npubCashUserInfo?.name || nip19.npubEncode(user.pubkey);
|
|
||||||
const lightningAddress = `${identifier}@npubx.cash`;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="mb-4 flex items-center justify-center gap-2">
|
|
||||||
<button
|
|
||||||
onClick={async () => {
|
|
||||||
await copyToClipboard(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">
|
|
||||||
{lightningAddress}
|
|
||||||
</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 qr = await generateQRCode(lightningAddress);
|
|
||||||
setLightningAddressQRCode(qr);
|
setLightningAddressQRCode(qr);
|
||||||
setShowLightningAddressQR(true);
|
setShowLightningAddressQR(true);
|
||||||
}}
|
}}
|
||||||
className="flex items-center justify-center px-2 py-1.5 hover:bg-muted rounded-md transition-colors h-[34px]"
|
generateQRCode={generateQRCode}
|
||||||
title="Show QR Code"
|
/>
|
||||||
>
|
|
||||||
<QrCode className="h-4 w-4" />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})()}
|
|
||||||
|
|
||||||
{/* ========================================================================
|
{/* ========================================================================
|
||||||
SECTION: Receive & Send Cards
|
SECTION: Receive & Send Cards
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ import { Button } from '@/components/ui/button';
|
|||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
|
||||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog';
|
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 { useCashuBalances } from '@/hooks/cashu/useCashuBalances';
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
interface CashuMint {
|
interface CashuMint {
|
||||||
url: string;
|
url: string;
|
||||||
@@ -26,6 +27,12 @@ interface BalanceDisplayProps {
|
|||||||
onRemoveMint: (mint: CashuMint) => void;
|
onRemoveMint: (mint: CashuMint) => void;
|
||||||
onShowDenominations: (mintUrl: string) => void;
|
onShowDenominations: (mintUrl: string) => void;
|
||||||
getCleanMintLabel: (mint: { name?: string; url: string }) => string;
|
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({
|
export function BalanceDisplay({
|
||||||
@@ -44,8 +51,14 @@ export function BalanceDisplay({
|
|||||||
onRemoveMint,
|
onRemoveMint,
|
||||||
onShowDenominations,
|
onShowDenominations,
|
||||||
getCleanMintLabel,
|
getCleanMintLabel,
|
||||||
|
userPubkey,
|
||||||
|
npubCashUsername,
|
||||||
|
onCopyToClipboard,
|
||||||
|
onShowLightningAddressQR,
|
||||||
|
generateQRCode,
|
||||||
}: BalanceDisplayProps) {
|
}: BalanceDisplayProps) {
|
||||||
const { convertCurrency } = useCashuBalances(null);
|
const { convertCurrency } = useCashuBalances(null);
|
||||||
|
const [lightningAddressCopied, setLightningAddressCopied] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="text-center py-2">
|
<div className="text-center py-2">
|
||||||
@@ -187,6 +200,41 @@ export function BalanceDisplay({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</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>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user