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">
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { X, Coins } from 'lucide-react';
|
||||
import { useCashuBalances } from '@/hooks/cashu/useCashuBalances';
|
||||
|
||||
interface ProofBreakdown {
|
||||
mintUrl: string;
|
||||
@@ -17,8 +16,6 @@ interface ProofBreakdownModalProps {
|
||||
}
|
||||
|
||||
export function ProofBreakdownModal({ isOpen, onClose, breakdown }: ProofBreakdownModalProps) {
|
||||
const { convertCurrency } = useCashuBalances(null);
|
||||
|
||||
if (!isOpen || !breakdown) return null;
|
||||
|
||||
return (
|
||||
@@ -50,7 +47,7 @@ export function ProofBreakdownModal({ isOpen, onClose, breakdown }: ProofBreakdo
|
||||
<CardContent className="space-y-4">
|
||||
<div className="text-center py-2">
|
||||
<div className="text-2xl font-bold text-primary">
|
||||
{convertCurrency(breakdown.totalBalance)}
|
||||
{breakdown.totalBalance.toLocaleString()} sats
|
||||
</div>
|
||||
<div className="text-sm text-muted-foreground">Total Balance</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user