mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 16:33:36 +00:00
code cleanup
This commit is contained in:
1 parent
dd3f4465c5
commit
5ce402105c
13 files changed
+277
-1042
No files matched your search
@@ -3,8 +3,8 @@ 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, QrCode, Copy, Check } from 'lucide-react';
|
||||
import { useCashuBalances } from '@/hooks/cashu/useCashuBalances';
|
||||
import { useState } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { exchangeRateService } from '@/lib/exchangeRateService';
|
||||
|
||||
interface CashuMint {
|
||||
url: string;
|
||||
@@ -57,8 +57,26 @@ export function BalanceDisplay({
|
||||
onShowLightningAddressQR,
|
||||
generateQRCode,
|
||||
}: BalanceDisplayProps) {
|
||||
const { convertCurrency } = useCashuBalances(null);
|
||||
const [lightningAddressCopied, setLightningAddressCopied] = useState(false);
|
||||
const [btcUsdRate, setBtcUsdRate] = useState<number | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
exchangeRateService.getBtcUsdRate()
|
||||
.then(rate => setBtcUsdRate(rate))
|
||||
.catch(() => setBtcUsdRate(null));
|
||||
}, []);
|
||||
|
||||
const convertCurrency = (sats: number, showSats: boolean): string => {
|
||||
if (showSats) {
|
||||
return `${sats.toLocaleString()} sats`;
|
||||
} else if (btcUsdRate) {
|
||||
const btcAmount = sats / 100000000;
|
||||
const usd = btcAmount * btcUsdRate;
|
||||
return `$${usd.toFixed(2)}`;
|
||||
} else {
|
||||
return `${sats.toLocaleString()} sats`;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="text-center py-2">
|
||||
|
||||
Reference in new issue
Block a user