transaction history drawer and separate mint display

This commit is contained in:
lemonknowsall committed 2025-10-18 00:22:50 -07:00
1 parent e4ee51335e
commit bea63c75aa
10 files changed
+348 -278

No files matched your search

+1 -1
View File
@@ -31,7 +31,7 @@ const queryClient = new QueryClient({
});
const defaultConfig: AppConfig = {
theme: "light",
theme: "system",
relayUrl: "wss://relay.primal.net",
};
+5 -11
View File
@@ -95,7 +95,7 @@ const WalletContent = forwardRef<HTMLDivElement, {
<div className="space-y-6 px-4 pb-4" ref={ref}>
{/* Primary Payment Method - Cashu */}
<div className="space-y-3">
<h3 className="font-medium">Primary Payment Method</h3>
<h3 className="font-medium">Primary Wallet</h3>
<div className="flex items-center justify-between p-3 border rounded-lg bg-muted/30">
<div className="flex items-center gap-3">
<Coins className="h-4 w-4 text-muted-foreground" />
@@ -116,19 +116,13 @@ const WalletContent = forwardRef<HTMLDivElement, {
</Badge>
</div>
</div>
<div className="text-xs text-muted-foreground text-center">
Cashu tokens are used first for Lightning zaps. Set up your Cashu wallet for instant payments.
</div>
</div>
<Separator />
{/* Lightning Fallback Methods */}
<div className="space-y-3">
<h3 className="font-medium">Lightning Fallback Methods</h3>
<div className="text-xs text-muted-foreground mb-3">
Used when Cashu balance is insufficient or unavailable
</div>
<h3 className="font-medium">Other Options</h3>
<div className="grid gap-3">
{/* WebLN */}
<div className="flex items-center justify-between p-3 border rounded-lg">
@@ -233,7 +227,7 @@ const WalletContent = forwardRef<HTMLDivElement, {
<Separator />
<div className="text-center py-4 space-y-2">
<p className="text-sm text-muted-foreground">
Set up your Cashu wallet for instant payments, or install a WebLN extension/connect NWC wallet for Lightning fallback.
Set up your Cashu wallet for instant payments, or install a WebLN extension/connect NWC wallet for Lightning
</p>
</div>
</>
@@ -367,7 +361,7 @@ export function LightningWalletModal({ children, className }: LightningWalletMod
Payment Settings
</DrawerTitle>
<DrawerDescription>
Manage Cashu wallet and Lightning fallback methods for zaps.
Manage wallet methods for zaps
</DrawerDescription>
</DrawerHeader>
<div className="overflow-y-auto">
@@ -423,7 +417,7 @@ export function LightningWalletModal({ children, className }: LightningWalletMod
Payment Settings
</DialogTitle>
<DialogDescription>
Manage Cashu wallet and Lightning fallback methods for zaps.
Manage wallet methods for zaps
</DialogDescription>
</DialogHeader>
<WalletContent {...walletContentProps} />
+1 -1
View File
@@ -31,7 +31,7 @@ export function LoginIcon() {
className="h-8 w-8 p-0"
title="Log in"
>
<User className="h-4 w-4" />
<User className="!h-6 !w-6" />
</Button>
<LoginDialog
+3 -3
View File
@@ -9,13 +9,13 @@ interface ActionButtonsProps {
export function ActionButtons({ onSendClick, onReceiveClick, isLoading }: ActionButtonsProps) {
return (
<div className="flex gap-8 justify-center py-8">
<div className="flex gap-20 justify-center py-8">
<Button
variant="outline"
size="icon"
onClick={onReceiveClick}
disabled={isLoading}
className="h-20 w-20 rounded-full bg-muted border-2 shadow-lg hover:shadow-xl transition-all duration-200 hover:scale-105 [&_svg]:size-6"
className="h-20 w-20 rounded-full bg-muted transition-all duration-200 hover:scale-105 [&_svg]:size-6"
>
<Download className="h-12 w-12" />
</Button>
@@ -25,7 +25,7 @@ export function ActionButtons({ onSendClick, onReceiveClick, isLoading }: Action
size="icon"
onClick={onSendClick}
disabled={isLoading}
className="h-20 w-20 rounded-full bg-muted border-2 shadow-lg hover:shadow-xl transition-all duration-200 hover:scale-105 [&_svg]:size-6"
className="h-20 w-20 rounded-full bg-muted transition-all duration-200 hover:scale-105 [&_svg]:size-6"
>
<Send className="h-12 w-12" />
</Button>
+2 -109
View File
@@ -1,39 +1,18 @@
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, QrCode, Copy, Check } from 'lucide-react';
import { QrCode, Copy, Check } from 'lucide-react';
import { useState, useEffect } from 'react';
import { exchangeRateService } from '@/lib/exchangeRateService';
interface CashuMint {
url: string;
name?: string;
}
interface BalanceDisplayProps {
totalBalance: number;
balances: { [key: string]: number };
showSats: boolean;
setShowSats: (showSats: boolean) => void;
activeMintUrl: string | null;
setActiveMintUrl: (url: string | null) => void;
mints: CashuMint[];
mintUrl: string;
setMintUrl: (url: string) => void;
onAddMint: () => void;
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>;
// Dropdown state
mintDropdownOpen: boolean;
setMintDropdownOpen: (open: boolean) => void;
}
export function BalanceDisplay({
@@ -41,22 +20,11 @@ export function BalanceDisplay({
balances,
showSats,
setShowSats,
activeMintUrl,
setActiveMintUrl,
mints,
mintUrl,
setMintUrl,
onAddMint,
onRemoveMint,
onShowDenominations,
getCleanMintLabel,
userPubkey,
npubCashUsername,
onCopyToClipboard,
onShowLightningAddressQR,
generateQRCode,
mintDropdownOpen,
setMintDropdownOpen,
}: BalanceDisplayProps) {
const [lightningAddressCopied, setLightningAddressCopied] = useState(false);
const [btcUsdRate, setBtcUsdRate] = useState<number | null>(null);
@@ -84,7 +52,7 @@ export function BalanceDisplay({
<div className="flex items-center justify-center gap-3">
<button
onClick={() => setShowSats(!showSats)}
className="text-5xl font-bold tabular-nums hover:opacity-80 transition-opacity cursor-pointer"
className="text-6xl font-bold tabular-nums hover:opacity-80 transition-opacity cursor-pointer"
title={`Click to show in ${showSats ? 'USD' : 'sats'}`}
>
<span className="text-muted-foreground italic">
@@ -93,81 +61,6 @@ export function BalanceDisplay({
{showSats ? totalBalance.toLocaleString() : (btcUsdRate ? `${(totalBalance / 100000000 * btcUsdRate).toFixed(2)}` : totalBalance.toLocaleString())}
</button>
</div>
{/* Active Mint Dropdown */}
<div className="mt-3 flex items-center justify-center gap-2">
{activeMintUrl && (
<button
onClick={() => activeMintUrl && onShowDenominations(activeMintUrl)}
className="p-2 rounded-lg hover:bg-muted transition-colors"
title="Show proof breakdown"
>
<Wallet className="h-4 w-4" />
</button>
)}
<DropdownMenu open={mintDropdownOpen} onOpenChange={setMintDropdownOpen}>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="sm" className="gap-2 text-muted-foreground hover:text-foreground text-base">
<div className="flex items-center gap-2">
<span>{activeMintUrl ? getCleanMintLabel({ url: activeMintUrl }) : 'Select Mint'}</span>
{activeMintUrl && (
<span>
{convertCurrency(balances[activeMintUrl] || 0, showSats)}
</span>
)}
</div>
<ChevronDown className="h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="center" className="w-72">
{mints.length === 0 && (
<DropdownMenuItem disabled>No mints connected</DropdownMenuItem>
)}
{mints
.filter((mint) => mint.url)
.map((mint, index) => (
<DropdownMenuItem
key={`dd-mint-${mint.url || `unknown-${index}`}`}
className="flex items-center justify-between"
onClick={() => setActiveMintUrl(mint.url)}
>
<div className="flex items-center gap-2">
<span className="font-medium">{getCleanMintLabel(mint)}</span>
<span className="text-xs text-muted-foreground">
{convertCurrency(balances[mint.url] || 0, showSats)}
</span>
</div>
<Button
size="sm"
variant="ghost"
className="h-6 w-6 p-0 hover:bg-destructive hover:text-destructive-foreground"
onClick={(e) => {
e.stopPropagation();
onRemoveMint(mint);
}}
>
<X className="h-3 w-3" />
</Button>
</DropdownMenuItem>
))}
<DropdownMenuSeparator />
<div className="px-2 py-1.5">
<div className="flex gap-2">
<Input
placeholder="mint.example.com"
value={mintUrl}
onChange={(e) => setMintUrl(e.target.value)}
className="h-8"
/>
<Button size="sm" onClick={onAddMint} disabled={!mintUrl.trim()}>
<Plus className="h-3.5 w-3.5 mr-1" />
Add
</Button>
</div>
</div>
</DropdownMenuContent>
</DropdownMenu>
</div>
{/* Lightning Address */}
{userPubkey && (
+88 -57
View File
@@ -12,6 +12,7 @@ import { useWalletTransactions } from '@/hooks/cashu/useWalletTransactions';
import { useHistoryManager } from '@/hooks/cashu/useHistoryManager';
import { QRModal } from '@/components/ui/qr-modal';
import { BalanceDisplay } from './BalanceDisplay';
import { MintDisplay } from './MintDisplay';
import { ActionButtons } from './ActionButtons';
import { ModeToggle } from './ModeToggle';
import { Drawer, DrawerContent, DrawerHeader, DrawerTitle } from '@/components/ui/drawer';
@@ -21,6 +22,7 @@ import { TransactionHistory } from './TransactionHistory';
import { ProofBreakdownModal } from './ProofBreakdownModal';
import { RemoveMintModal } from './RemoveMintModal';
import { LoginIcon } from '@/components/auth/LoginIcon';
import { ChevronUp } from 'lucide-react';
export function CashuWallet() {
// ============================================================================
@@ -163,6 +165,7 @@ export function CashuWallet() {
const [npubCashUserInfo, setNpubCashUserInfo] = useState<NpubCashUserInfo | null>(null);
const [showSendModal, setShowSendModal] = useState(false);
const [showReceiveModal, setShowReceiveModal] = useState(false);
const [showHistoryModal, setShowHistoryModal] = useState(false);
// Ref to track if we've fetched npub.cash user info
const hasCheckedNpubCashRef = useRef(false);
@@ -277,7 +280,7 @@ export function CashuWallet() {
return (
<>
<div className="max-w-4xl mx-auto pt-16 pb-1 px-3 sm:px-4 relative">
<div className="max-w-4xl mx-auto pt-16 pb-32 px-3 sm:px-4 relative">
{/* Mode Toggle */}
<div className="absolute top-3 left-3 sm:left-4 z-10">
@@ -289,60 +292,74 @@ export function CashuWallet() {
<LoginIcon />
</div>
{/* Balance Display */}
<BalanceDisplay
totalBalance={totalBalance}
balances={balances}
showSats={showSats}
setShowSats={setShowSats}
activeMintUrl={activeMintUrl}
setActiveMintUrl={handleSetActiveMintSync}
mints={mints}
mintUrl={mintUrl}
setMintUrl={setMintUrl}
onAddMint={handleAddMint}
onRemoveMint={handleRemoveMintClick}
onShowDenominations={(mintUrl) => handleShowDenominations(mintUrl, setShowProofBreakdown, setProofBreakdown)}
getCleanMintLabel={getCleanMintLabel}
userPubkey={user?.pubkey}
npubCashUsername={user?.pubkey ? (npubCashUserInfo?.name || nip19.npubEncode(user.pubkey)) : undefined}
onCopyToClipboard={copyToClipboard}
onShowLightningAddressQR={(qr) => {
setLightningAddressQRCode(qr);
setShowLightningAddressQR(true);
}}
generateQRCode={generateQRCode}
mintDropdownOpen={mintDropdownOpen}
setMintDropdownOpen={setMintDropdownOpen}
/>
{/* Action Buttons */}
<ActionButtons
onSendClick={() => setShowSendModal(true)}
onReceiveClick={() => setShowReceiveModal(true)}
isLoading={isLoading || isNpubCashLoading}
/>
{/* Sent Token Display */}
{sentToken && (
<QRModal
isOpen={!!sentToken}
onClose={() => setSentToken(null)}
title="Cashu Token"
description="Share this token with the recipient to send them your sats"
qrCodeUrl={sentTokenQRCode}
content={sentToken}
icon="qr"
{/* Centered Balance and Mint Display */}
<div className="flex flex-col items-center pt-10 space-y-2">
{/* Balance Display */}
<BalanceDisplay
totalBalance={totalBalance}
balances={balances}
showSats={showSats}
setShowSats={setShowSats}
userPubkey={user?.pubkey}
npubCashUsername={user?.pubkey ? (npubCashUserInfo?.name || nip19.npubEncode(user.pubkey)) : undefined}
onCopyToClipboard={copyToClipboard}
onShowLightningAddressQR={(qr) => {
setLightningAddressQRCode(qr);
setShowLightningAddressQR(true);
}}
generateQRCode={generateQRCode}
/>
)}
{/* Transaction History */}
<TransactionHistory
entries={historyEntries}
isLoading={isLoadingHistory}
isExpanded={isHistoryExpanded}
setIsExpanded={setIsHistoryExpanded}
/>
{/* Mint Display */}
<MintDisplay
balances={balances}
showSats={showSats}
activeMintUrl={activeMintUrl}
setActiveMintUrl={handleSetActiveMintSync}
mints={mints}
mintUrl={mintUrl}
setMintUrl={setMintUrl}
onAddMint={handleAddMint}
onRemoveMint={handleRemoveMintClick}
onShowDenominations={(mintUrl) => handleShowDenominations(mintUrl, setShowProofBreakdown, setProofBreakdown)}
getCleanMintLabel={getCleanMintLabel}
dropdownOpen={mintDropdownOpen}
setDropdownOpen={setMintDropdownOpen}
/>
</div>
{/* Action Buttons and Transaction History Container */}
<div className="fixed bottom-0 left-0 right-0 pb-8 pb-safe">
{/* Action Buttons */}
<ActionButtons
onSendClick={() => setShowSendModal(true)}
onReceiveClick={() => setShowReceiveModal(true)}
isLoading={isLoading || isNpubCashLoading}
/>
{/* Sent Token Display */}
{sentToken && (
<QRModal
isOpen={!!sentToken}
onClose={() => setSentToken(null)}
title="Cashu Token"
description="Share this token with the recipient to send them your sats"
qrCodeUrl={sentTokenQRCode}
content={sentToken}
icon="qr"
/>
)}
{/* Transaction History Button */}
<div className="max-w-4xl mx-auto">
<button
onClick={() => setShowHistoryModal(true)}
className="w-full py-2 px-4 flex justify-center border-t border-muted hover:bg-muted/30 transition-colors"
>
<ChevronUp className="h-5 w-5 text-muted-foreground" />
</button>
</div>
</div>
{/* Modals */}
<>
@@ -414,9 +431,9 @@ export function CashuWallet() {
{/* Bottom Drawer Modals */}
<Drawer open={showSendModal} onOpenChange={setShowSendModal}>
<DrawerContent className="min-h-[50vh] max-h-[85vh] max-w-4xl mx-auto">
<DrawerContent className="h-[50vh] max-w-4xl mx-auto">
<DrawerHeader>
<DrawerTitle></DrawerTitle>
<DrawerTitle className="text-center text-3xl font-bold">Send</DrawerTitle>
</DrawerHeader>
<div className="px-4 pb-4">
<SendCard
@@ -449,9 +466,9 @@ export function CashuWallet() {
</Drawer>
<Drawer open={showReceiveModal} onOpenChange={setShowReceiveModal}>
<DrawerContent className="min-h-[50vh] max-h-[85vh] max-w-4xl mx-auto">
<DrawerContent className="h-[50vh] max-w-4xl mx-auto">
<DrawerHeader>
<DrawerTitle></DrawerTitle>
<DrawerTitle className="text-center text-3xl font-bold">Receive</DrawerTitle>
</DrawerHeader>
<div className="px-4 pb-4">
<ReceiveCard
@@ -470,6 +487,20 @@ export function CashuWallet() {
</div>
</DrawerContent>
</Drawer>
<Drawer open={showHistoryModal} onOpenChange={setShowHistoryModal}>
<DrawerContent className="max-h-[90vh] max-w-4xl mx-auto">
<DrawerHeader>
<DrawerTitle className="text-center text-3xl font-bold">Transactions</DrawerTitle>
</DrawerHeader>
<div className="px-4 pb-4 overflow-y-auto flex-1">
<TransactionHistory
entries={historyEntries}
isLoading={isLoadingHistory}
/>
</div>
</DrawerContent>
</Drawer>
</>
</div>
</>
+182
View File
@@ -0,0 +1,182 @@
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Plus, X, Check, ChevronDown } from 'lucide-react';
import { useState, useEffect } from 'react';
import { exchangeRateService } from '@/lib/exchangeRateService';
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
DropdownMenuSeparator,
} from '@/components/ui/dropdown-menu';
interface CashuMint {
url: string;
name?: string;
}
interface MintDisplayProps {
balances: { [key: string]: number };
showSats: boolean;
activeMintUrl: string | null;
setActiveMintUrl: (url: string | null) => void;
mints: CashuMint[];
mintUrl: string;
setMintUrl: (url: string) => void;
onAddMint: () => void;
onRemoveMint: (mint: CashuMint) => void;
onShowDenominations: (mintUrl: string) => void;
getCleanMintLabel: (mint: { name?: string; url: string }) => string;
dropdownOpen: boolean;
setDropdownOpen: (open: boolean) => void;
}
export function MintDisplay({
balances,
showSats,
activeMintUrl,
setActiveMintUrl,
mints,
mintUrl,
setMintUrl,
onAddMint,
onRemoveMint,
onShowDenominations,
getCleanMintLabel,
dropdownOpen,
setDropdownOpen,
}: MintDisplayProps) {
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()}`;
} else if (btcUsdRate) {
const btcAmount = sats / 100000000;
const usd = btcAmount * btcUsdRate;
return `$${usd.toFixed(2)}`;
} else {
return `₿${sats.toLocaleString()}`;
}
};
const activeMint = mints.find(mint => mint.url === activeMintUrl);
const activeBalance = activeMint ? balances[activeMint.url] || 0 : 0;
return (
<div className="w-full max-w-[400px] mx-auto space-y-4">
{/* Mint Selector Dropdown */}
<div>
<DropdownMenu open={dropdownOpen} onOpenChange={setDropdownOpen}>
<DropdownMenuTrigger asChild>
<Button variant="outline" className="w-full justify-between rounded-full bg-muted hover:bg-muted/80 border-muted text-base">
<div className="flex items-center justify-between w-full">
{activeMint ? (
<>
<div className="flex items-center gap-2 min-w-0 flex-1">
<Check className="h-5 w-5 text-primary flex-shrink-0" />
<span className="truncate font-medium">{getCleanMintLabel(activeMint)}</span>
</div>
<span className="text-muted-foreground font-medium">
{convertCurrency(activeBalance, showSats)}
</span>
</>
) : (
<span className="text-muted-foreground">Select a mint</span>
)}
</div>
<ChevronDown className="h-5 w-5 ml-2" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-[var(--radix-dropdown-menu-trigger-width)] bg-muted border-muted">
{mints
.filter((mint) => mint.url)
.map((mint, index) => {
const isActive = activeMintUrl === mint.url;
const balance = balances[mint.url] || 0;
return (
<DropdownMenuItem
key={`mint-${mint.url || `unknown-${index}`}`}
onClick={() => setActiveMintUrl(mint.url)}
className="flex items-center justify-between p-3 text-base"
>
<div className="flex items-center gap-3 flex-1 min-w-0">
{isActive && (
<div className="flex-shrink-0">
<Check className="h-5 w-5 text-primary" />
</div>
)}
<div className="flex-1 min-w-0">
<div className="font-medium truncate">
{getCleanMintLabel(mint)}
</div>
</div>
</div>
<div className="flex items-center gap-2 flex-shrink-0">
<span className="px-3 py-1 text-sm font-medium text-muted-foreground">
{convertCurrency(balance, showSats)}
</span>
<button
onClick={(e) => {
e.stopPropagation();
onRemoveMint(mint);
}}
className="p-1 rounded hover:bg-destructive hover:text-destructive-foreground transition-colors"
title="Remove mint"
>
<X className="h-4 w-4" />
</button>
</div>
</DropdownMenuItem>
);
})}
{mints.length > 0 && <DropdownMenuSeparator />}
<DropdownMenuItem asChild>
<div className="flex gap-2 p-2">
<Input
placeholder="mint.example.com"
value={mintUrl}
onChange={(e) => setMintUrl(e.target.value)}
className="flex-1"
onClick={(e) => e.stopPropagation()}
onKeyDown={(e) => {
e.stopPropagation();
// Prevent dropdown from closing on keyboard input
if (e.key === 'Escape') {
setDropdownOpen(false);
} else if (e.key === 'Enter') {
e.preventDefault();
if (mintUrl.trim()) {
onAddMint();
}
}
}}
onKeyUp={(e) => e.stopPropagation()}
/>
<Button
onClick={(e) => {
e.stopPropagation();
onAddMint();
}}
disabled={!mintUrl.trim()}
size="sm"
>
<Plus className="h-4 w-4 mr-1" />
Add
</Button>
</div>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
);
}
+5 -10
View File
@@ -27,10 +27,7 @@ export function ReceiveCard({
<div className="space-y-8">
{/* Title */}
<div className="text-center">
<h2 className="text-3xl font-bold text-foreground">
Receive
</h2>
<p className="!text-xl text-muted-foreground mt-2">
<p className="text-base text-muted-foreground mt-2">
{mode === 'tokens'
? 'Enter Cashu token to redeem'
: 'Deposit funds with Lightning'
@@ -58,14 +55,13 @@ export function ReceiveCard({
}
}}
disabled={!activeMintUrl}
autoFocus
className="w-full h-16 !text-xl text-center border-0 bg-transparent focus:ring-0 focus:ring-offset-0"
className="w-full h-16 !text-base text-center border bg-background focus:ring-2 focus:ring-ring focus:ring-offset-2"
/>
<div className="flex justify-center mt-4">
<Button
onClick={onReceive}
disabled={!tokenInput.trim() || !activeMintUrl || isLoading}
className="h-12 px-8 rounded-full"
className="h-12 px-12 rounded-full"
size="lg"
>
<Download className="h-5 w-5" />
@@ -92,14 +88,13 @@ export function ReceiveCard({
}
}}
disabled={!activeMintUrl}
autoFocus
className="w-full h-16 !text-xl text-center border-0 bg-transparent focus:ring-0 focus:ring-offset-0 [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none [-moz-appearance:textfield]"
className="w-full h-16 !text-base text-center border bg-background focus:ring-2 focus:ring-ring focus:ring-offset-2 [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none [-moz-appearance:textfield]"
/>
<div className="flex justify-center mt-4">
<Button
onClick={onReceive}
disabled={!quoteAmount || !activeMintUrl || isLoading}
className="h-12 px-8 rounded-full"
className="h-12 px-12 rounded-full"
size="lg"
>
<Zap className="h-5 w-5" />
+7 -13
View File
@@ -41,10 +41,7 @@ export function SendCard({
<div className="space-y-8">
{/* Title */}
<div className="text-center">
<h2 className="text-3xl font-bold text-foreground">
Send
</h2>
<p className="!text-xl text-muted-foreground mt-2">
<p className="text-base text-muted-foreground mt-2">
{mode === 'tokens'
? 'Generate Cashu token to send'
: pendingLightningAddress
@@ -80,14 +77,13 @@ export function SendCard({
}
}}
disabled={!activeMintUrl}
autoFocus
className="w-full h-16 !text-xl text-center border-0 bg-transparent focus:ring-0 focus:ring-offset-0 [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none [-moz-appearance:textfield]"
className="w-full h-16 !text-base text-center border bg-background focus:ring-2 focus:ring-ring focus:ring-offset-2 [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none [-moz-appearance:textfield]"
/>
<div className="flex justify-center mt-4">
<Button
onClick={onSend}
disabled={!sendAmount || !activeMintUrl || isLoading}
className="h-12 px-8 rounded-full"
className="h-12 px-12 rounded-full"
size="lg"
>
<Send className="h-5 w-5" />
@@ -115,15 +111,14 @@ export function SendCard({
onSend();
}
}}
autoFocus
disabled={!activeMintUrl}
className="w-full h-16 !text-xl text-center border-0 bg-transparent focus:ring-0 focus:ring-offset-0 [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none [-moz-appearance:textfield]"
className="w-full h-16 !text-base text-center border bg-background focus:ring-2 focus:ring-ring focus:ring-offset-2 [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none [-moz-appearance:textfield]"
/>
<div className="flex justify-center gap-2 mt-4">
<Button
onClick={onSend}
disabled={!lightningAddressAmount || !activeMintUrl || isResolvingAddress || isLoading}
className="h-12 px-8 rounded-full"
className="h-12 px-12 rounded-full"
size="lg"
>
{isResolvingAddress ? (
@@ -168,14 +163,13 @@ export function SendCard({
}
}}
disabled={!activeMintUrl}
autoFocus
className="w-full h-16 !text-xl text-center border-0 bg-transparent focus:ring-0 focus:ring-offset-0"
className="w-full h-16 !text-base text-center border bg-background focus:ring-2 focus:ring-ring focus:ring-offset-2"
/>
<div className="flex justify-center mt-4">
<Button
onClick={onSend}
disabled={(!lightningInvoice.trim() && !lightningAddressInput.trim()) || !activeMintUrl || isLoading}
className="h-12 px-8 rounded-full"
className="h-12 px-12 rounded-full"
size="lg"
>
<Zap className="h-5 w-5" />
+54 -73
View File
@@ -1,14 +1,12 @@
import { Loader2, History, ArrowUpRight, ArrowDownLeft, Zap, ChevronDown, ChevronUp, Coins } from 'lucide-react';
import { Loader2, History, ArrowUpRight, ArrowDownLeft, Zap, Coins } from 'lucide-react';
import type { HistoryEntry } from 'coco-cashu-core';
interface TransactionHistoryProps {
entries: HistoryEntry[];
isLoading: boolean;
isExpanded: boolean;
setIsExpanded: (expanded: boolean) => void;
}
export function TransactionHistory({ entries, isLoading, isExpanded, setIsExpanded }: TransactionHistoryProps) {
export function TransactionHistory({ entries, isLoading }: TransactionHistoryProps) {
// Icon indicating transaction type (Lightning vs Cashu)
const getTransactionTypeIcon = (type: string) => {
switch (type) {
@@ -50,80 +48,63 @@ export function TransactionHistory({ entries, isLoading, isExpanded, setIsExpand
}
};
if (entries.length === 0 && !isLoading) {
return null;
}
return (
<div className="mt-6">
{/* Collapsible Section Header */}
<button
onClick={() => setIsExpanded(!isExpanded)}
className="w-full py-2 px-4 flex justify-center border-t border-muted hover:bg-muted/30 transition-colors"
>
{isExpanded ? (
<ChevronUp className="h-5 w-5 text-muted-foreground" />
) : (
<ChevronDown className="h-5 w-5 text-muted-foreground" />
)}
</button>
{/* Transactions List - Only shown when expanded */}
{isExpanded && (
<div className="mt-4 space-y-2">
{isLoading ? (
<div className="flex items-center justify-center py-8">
<Loader2 className="h-6 w-6 animate-spin mr-2" />
<span>Loading history...</span>
</div>
) : (
<>
{entries.map((entry) => (
<div
key={entry.id}
className="rounded-lg p-4 hover:bg-muted/50 transition-colors"
>
<div className="flex items-start justify-between">
<div className="flex items-start gap-3 flex-1">
<div className="mt-1">
{getTransactionTypeIcon(entry.type)}
</div>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2 flex-wrap">
<span className="font-medium">
{getHistoryLabel(entry.type)}
</span>
</div>
<div className="text-sm text-muted-foreground mt-1">
{new URL(entry.mintUrl).hostname}
</div>
<div className="text-xs text-muted-foreground mt-1">
{new Date(entry.createdAt).toLocaleString()}
</div>
</div>
<div className="space-y-2">
{isLoading ? (
<div className="flex items-center justify-center py-8">
<Loader2 className="h-6 w-6 animate-spin mr-2" />
<span>Loading history...</span>
</div>
) : entries.length === 0 ? (
<div className="text-center py-8 text-muted-foreground">
No transactions yet
</div>
) : (
<>
{entries.map((entry) => (
<div
key={entry.id}
className="rounded-lg p-4 hover:bg-muted/50 transition-colors"
>
<div className="flex items-start justify-between">
<div className="flex items-start gap-3 flex-1">
<div className="mt-1">
{getTransactionTypeIcon(entry.type)}
</div>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2 flex-wrap">
<span className="font-medium">
{getHistoryLabel(entry.type)}
</span>
</div>
<div className="text-right ml-4 flex items-start gap-2">
<div>
<div className="font-semibold">
{entry.type === 'send' || entry.type === 'melt' ? '-' : '+'}
{entry.amount.toLocaleString()} {entry.unit}
</div>
{entry.type === 'melt' && (
<div className="text-xs text-muted-foreground mt-1">
+ fees
</div>
)}
</div>
<div className="mt-1">
{getDirectionIcon(entry.type)}
</div>
<div className="text-sm text-muted-foreground mt-1">
{new URL(entry.mintUrl).hostname}
</div>
<div className="text-xs text-muted-foreground mt-1">
{new Date(entry.createdAt).toLocaleString()}
</div>
</div>
</div>
))}
</>
)}
</div>
<div className="text-right ml-4 flex items-start gap-2">
<div>
<div className="font-semibold">
{entry.type === 'send' || entry.type === 'melt' ? '-' : '+'}
{entry.amount.toLocaleString()} {entry.unit}
</div>
{entry.type === 'melt' && (
<div className="text-xs text-muted-foreground mt-1">
+ fees
</div>
)}
</div>
<div className="mt-1">
{getDirectionIcon(entry.type)}
</div>
</div>
</div>
</div>
))}
</>
)}
</div>
);