mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-06 00:37:23 +00:00
transaction history drawer and separate mint display
This commit is contained in:
1 parent
e4ee51335e
commit
bea63c75aa
10 files changed
+348
-278
No files matched your search
+1
-1
@@ -31,7 +31,7 @@ const queryClient = new QueryClient({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const defaultConfig: AppConfig = {
|
const defaultConfig: AppConfig = {
|
||||||
theme: "light",
|
theme: "system",
|
||||||
relayUrl: "wss://relay.primal.net",
|
relayUrl: "wss://relay.primal.net",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ const WalletContent = forwardRef<HTMLDivElement, {
|
|||||||
<div className="space-y-6 px-4 pb-4" ref={ref}>
|
<div className="space-y-6 px-4 pb-4" ref={ref}>
|
||||||
{/* Primary Payment Method - Cashu */}
|
{/* Primary Payment Method - Cashu */}
|
||||||
<div className="space-y-3">
|
<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 justify-between p-3 border rounded-lg bg-muted/30">
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<Coins className="h-4 w-4 text-muted-foreground" />
|
<Coins className="h-4 w-4 text-muted-foreground" />
|
||||||
@@ -116,19 +116,13 @@ const WalletContent = forwardRef<HTMLDivElement, {
|
|||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
</div>
|
||||||
|
|
||||||
<Separator />
|
<Separator />
|
||||||
|
|
||||||
{/* Lightning Fallback Methods */}
|
{/* Lightning Fallback Methods */}
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<h3 className="font-medium">Lightning Fallback Methods</h3>
|
<h3 className="font-medium">Other Options</h3>
|
||||||
<div className="text-xs text-muted-foreground mb-3">
|
|
||||||
Used when Cashu balance is insufficient or unavailable
|
|
||||||
</div>
|
|
||||||
<div className="grid gap-3">
|
<div className="grid gap-3">
|
||||||
{/* WebLN */}
|
{/* WebLN */}
|
||||||
<div className="flex items-center justify-between p-3 border rounded-lg">
|
<div className="flex items-center justify-between p-3 border rounded-lg">
|
||||||
@@ -233,7 +227,7 @@ const WalletContent = forwardRef<HTMLDivElement, {
|
|||||||
<Separator />
|
<Separator />
|
||||||
<div className="text-center py-4 space-y-2">
|
<div className="text-center py-4 space-y-2">
|
||||||
<p className="text-sm text-muted-foreground">
|
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
@@ -367,7 +361,7 @@ export function LightningWalletModal({ children, className }: LightningWalletMod
|
|||||||
Payment Settings
|
Payment Settings
|
||||||
</DrawerTitle>
|
</DrawerTitle>
|
||||||
<DrawerDescription>
|
<DrawerDescription>
|
||||||
Manage Cashu wallet and Lightning fallback methods for zaps.
|
Manage wallet methods for zaps
|
||||||
</DrawerDescription>
|
</DrawerDescription>
|
||||||
</DrawerHeader>
|
</DrawerHeader>
|
||||||
<div className="overflow-y-auto">
|
<div className="overflow-y-auto">
|
||||||
@@ -423,7 +417,7 @@ export function LightningWalletModal({ children, className }: LightningWalletMod
|
|||||||
Payment Settings
|
Payment Settings
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Manage Cashu wallet and Lightning fallback methods for zaps.
|
Manage wallet methods for zaps
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<WalletContent {...walletContentProps} />
|
<WalletContent {...walletContentProps} />
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export function LoginIcon() {
|
|||||||
className="h-8 w-8 p-0"
|
className="h-8 w-8 p-0"
|
||||||
title="Log in"
|
title="Log in"
|
||||||
>
|
>
|
||||||
<User className="h-4 w-4" />
|
<User className="!h-6 !w-6" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<LoginDialog
|
<LoginDialog
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ interface ActionButtonsProps {
|
|||||||
|
|
||||||
export function ActionButtons({ onSendClick, onReceiveClick, isLoading }: ActionButtonsProps) {
|
export function ActionButtons({ onSendClick, onReceiveClick, isLoading }: ActionButtonsProps) {
|
||||||
return (
|
return (
|
||||||
<div className="flex gap-8 justify-center py-8">
|
<div className="flex gap-20 justify-center py-8">
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="icon"
|
size="icon"
|
||||||
onClick={onReceiveClick}
|
onClick={onReceiveClick}
|
||||||
disabled={isLoading}
|
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" />
|
<Download className="h-12 w-12" />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -25,7 +25,7 @@ export function ActionButtons({ onSendClick, onReceiveClick, isLoading }: Action
|
|||||||
size="icon"
|
size="icon"
|
||||||
onClick={onSendClick}
|
onClick={onSendClick}
|
||||||
disabled={isLoading}
|
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" />
|
<Send className="h-12 w-12" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,39 +1,18 @@
|
|||||||
import { Button } from '@/components/ui/button';
|
import { QrCode, Copy, Check } from 'lucide-react';
|
||||||
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 { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { exchangeRateService } from '@/lib/exchangeRateService';
|
import { exchangeRateService } from '@/lib/exchangeRateService';
|
||||||
|
|
||||||
interface CashuMint {
|
|
||||||
url: string;
|
|
||||||
name?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BalanceDisplayProps {
|
interface BalanceDisplayProps {
|
||||||
totalBalance: number;
|
totalBalance: number;
|
||||||
balances: { [key: string]: number };
|
balances: { [key: string]: number };
|
||||||
showSats: boolean;
|
showSats: boolean;
|
||||||
setShowSats: (showSats: boolean) => void;
|
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
|
// Lightning address props
|
||||||
userPubkey?: string;
|
userPubkey?: string;
|
||||||
npubCashUsername?: string;
|
npubCashUsername?: string;
|
||||||
onCopyToClipboard: (text: string) => Promise<void>;
|
onCopyToClipboard: (text: string) => Promise<void>;
|
||||||
onShowLightningAddressQR: (qrCode: string) => void;
|
onShowLightningAddressQR: (qrCode: string) => void;
|
||||||
generateQRCode: (text: string) => Promise<string>;
|
generateQRCode: (text: string) => Promise<string>;
|
||||||
// Dropdown state
|
|
||||||
mintDropdownOpen: boolean;
|
|
||||||
setMintDropdownOpen: (open: boolean) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function BalanceDisplay({
|
export function BalanceDisplay({
|
||||||
@@ -41,22 +20,11 @@ export function BalanceDisplay({
|
|||||||
balances,
|
balances,
|
||||||
showSats,
|
showSats,
|
||||||
setShowSats,
|
setShowSats,
|
||||||
activeMintUrl,
|
|
||||||
setActiveMintUrl,
|
|
||||||
mints,
|
|
||||||
mintUrl,
|
|
||||||
setMintUrl,
|
|
||||||
onAddMint,
|
|
||||||
onRemoveMint,
|
|
||||||
onShowDenominations,
|
|
||||||
getCleanMintLabel,
|
|
||||||
userPubkey,
|
userPubkey,
|
||||||
npubCashUsername,
|
npubCashUsername,
|
||||||
onCopyToClipboard,
|
onCopyToClipboard,
|
||||||
onShowLightningAddressQR,
|
onShowLightningAddressQR,
|
||||||
generateQRCode,
|
generateQRCode,
|
||||||
mintDropdownOpen,
|
|
||||||
setMintDropdownOpen,
|
|
||||||
}: BalanceDisplayProps) {
|
}: BalanceDisplayProps) {
|
||||||
const [lightningAddressCopied, setLightningAddressCopied] = useState(false);
|
const [lightningAddressCopied, setLightningAddressCopied] = useState(false);
|
||||||
const [btcUsdRate, setBtcUsdRate] = useState<number | null>(null);
|
const [btcUsdRate, setBtcUsdRate] = useState<number | null>(null);
|
||||||
@@ -84,7 +52,7 @@ export function BalanceDisplay({
|
|||||||
<div className="flex items-center justify-center gap-3">
|
<div className="flex items-center justify-center gap-3">
|
||||||
<button
|
<button
|
||||||
onClick={() => setShowSats(!showSats)}
|
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'}`}
|
title={`Click to show in ${showSats ? 'USD' : 'sats'}`}
|
||||||
>
|
>
|
||||||
<span className="text-muted-foreground italic">
|
<span className="text-muted-foreground italic">
|
||||||
@@ -93,81 +61,6 @@ export function BalanceDisplay({
|
|||||||
{showSats ? totalBalance.toLocaleString() : (btcUsdRate ? `${(totalBalance / 100000000 * btcUsdRate).toFixed(2)}` : totalBalance.toLocaleString())}
|
{showSats ? totalBalance.toLocaleString() : (btcUsdRate ? `${(totalBalance / 100000000 * btcUsdRate).toFixed(2)}` : totalBalance.toLocaleString())}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</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 */}
|
{/* Lightning Address */}
|
||||||
{userPubkey && (
|
{userPubkey && (
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { useWalletTransactions } from '@/hooks/cashu/useWalletTransactions';
|
|||||||
import { useHistoryManager } from '@/hooks/cashu/useHistoryManager';
|
import { useHistoryManager } from '@/hooks/cashu/useHistoryManager';
|
||||||
import { QRModal } from '@/components/ui/qr-modal';
|
import { QRModal } from '@/components/ui/qr-modal';
|
||||||
import { BalanceDisplay } from './BalanceDisplay';
|
import { BalanceDisplay } from './BalanceDisplay';
|
||||||
|
import { MintDisplay } from './MintDisplay';
|
||||||
import { ActionButtons } from './ActionButtons';
|
import { ActionButtons } from './ActionButtons';
|
||||||
import { ModeToggle } from './ModeToggle';
|
import { ModeToggle } from './ModeToggle';
|
||||||
import { Drawer, DrawerContent, DrawerHeader, DrawerTitle } from '@/components/ui/drawer';
|
import { Drawer, DrawerContent, DrawerHeader, DrawerTitle } from '@/components/ui/drawer';
|
||||||
@@ -21,6 +22,7 @@ import { TransactionHistory } from './TransactionHistory';
|
|||||||
import { ProofBreakdownModal } from './ProofBreakdownModal';
|
import { ProofBreakdownModal } from './ProofBreakdownModal';
|
||||||
import { RemoveMintModal } from './RemoveMintModal';
|
import { RemoveMintModal } from './RemoveMintModal';
|
||||||
import { LoginIcon } from '@/components/auth/LoginIcon';
|
import { LoginIcon } from '@/components/auth/LoginIcon';
|
||||||
|
import { ChevronUp } from 'lucide-react';
|
||||||
|
|
||||||
export function CashuWallet() {
|
export function CashuWallet() {
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -163,6 +165,7 @@ export function CashuWallet() {
|
|||||||
const [npubCashUserInfo, setNpubCashUserInfo] = useState<NpubCashUserInfo | null>(null);
|
const [npubCashUserInfo, setNpubCashUserInfo] = useState<NpubCashUserInfo | null>(null);
|
||||||
const [showSendModal, setShowSendModal] = useState(false);
|
const [showSendModal, setShowSendModal] = useState(false);
|
||||||
const [showReceiveModal, setShowReceiveModal] = useState(false);
|
const [showReceiveModal, setShowReceiveModal] = useState(false);
|
||||||
|
const [showHistoryModal, setShowHistoryModal] = useState(false);
|
||||||
|
|
||||||
// Ref to track if we've fetched npub.cash user info
|
// Ref to track if we've fetched npub.cash user info
|
||||||
const hasCheckedNpubCashRef = useRef(false);
|
const hasCheckedNpubCashRef = useRef(false);
|
||||||
@@ -277,7 +280,7 @@ export function CashuWallet() {
|
|||||||
|
|
||||||
return (
|
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 */}
|
{/* Mode Toggle */}
|
||||||
<div className="absolute top-3 left-3 sm:left-4 z-10">
|
<div className="absolute top-3 left-3 sm:left-4 z-10">
|
||||||
@@ -289,60 +292,74 @@ export function CashuWallet() {
|
|||||||
<LoginIcon />
|
<LoginIcon />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Balance Display */}
|
{/* Centered Balance and Mint Display */}
|
||||||
<BalanceDisplay
|
<div className="flex flex-col items-center pt-10 space-y-2">
|
||||||
totalBalance={totalBalance}
|
{/* Balance Display */}
|
||||||
balances={balances}
|
<BalanceDisplay
|
||||||
showSats={showSats}
|
totalBalance={totalBalance}
|
||||||
setShowSats={setShowSats}
|
balances={balances}
|
||||||
activeMintUrl={activeMintUrl}
|
showSats={showSats}
|
||||||
setActiveMintUrl={handleSetActiveMintSync}
|
setShowSats={setShowSats}
|
||||||
mints={mints}
|
userPubkey={user?.pubkey}
|
||||||
mintUrl={mintUrl}
|
npubCashUsername={user?.pubkey ? (npubCashUserInfo?.name || nip19.npubEncode(user.pubkey)) : undefined}
|
||||||
setMintUrl={setMintUrl}
|
onCopyToClipboard={copyToClipboard}
|
||||||
onAddMint={handleAddMint}
|
onShowLightningAddressQR={(qr) => {
|
||||||
onRemoveMint={handleRemoveMintClick}
|
setLightningAddressQRCode(qr);
|
||||||
onShowDenominations={(mintUrl) => handleShowDenominations(mintUrl, setShowProofBreakdown, setProofBreakdown)}
|
setShowLightningAddressQR(true);
|
||||||
getCleanMintLabel={getCleanMintLabel}
|
}}
|
||||||
userPubkey={user?.pubkey}
|
generateQRCode={generateQRCode}
|
||||||
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"
|
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Transaction History */}
|
{/* Mint Display */}
|
||||||
<TransactionHistory
|
<MintDisplay
|
||||||
entries={historyEntries}
|
balances={balances}
|
||||||
isLoading={isLoadingHistory}
|
showSats={showSats}
|
||||||
isExpanded={isHistoryExpanded}
|
activeMintUrl={activeMintUrl}
|
||||||
setIsExpanded={setIsHistoryExpanded}
|
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 */}
|
{/* Modals */}
|
||||||
<>
|
<>
|
||||||
@@ -414,9 +431,9 @@ export function CashuWallet() {
|
|||||||
|
|
||||||
{/* Bottom Drawer Modals */}
|
{/* Bottom Drawer Modals */}
|
||||||
<Drawer open={showSendModal} onOpenChange={setShowSendModal}>
|
<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>
|
<DrawerHeader>
|
||||||
<DrawerTitle></DrawerTitle>
|
<DrawerTitle className="text-center text-3xl font-bold">Send</DrawerTitle>
|
||||||
</DrawerHeader>
|
</DrawerHeader>
|
||||||
<div className="px-4 pb-4">
|
<div className="px-4 pb-4">
|
||||||
<SendCard
|
<SendCard
|
||||||
@@ -449,9 +466,9 @@ export function CashuWallet() {
|
|||||||
</Drawer>
|
</Drawer>
|
||||||
|
|
||||||
<Drawer open={showReceiveModal} onOpenChange={setShowReceiveModal}>
|
<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>
|
<DrawerHeader>
|
||||||
<DrawerTitle></DrawerTitle>
|
<DrawerTitle className="text-center text-3xl font-bold">Receive</DrawerTitle>
|
||||||
</DrawerHeader>
|
</DrawerHeader>
|
||||||
<div className="px-4 pb-4">
|
<div className="px-4 pb-4">
|
||||||
<ReceiveCard
|
<ReceiveCard
|
||||||
@@ -470,6 +487,20 @@ export function CashuWallet() {
|
|||||||
</div>
|
</div>
|
||||||
</DrawerContent>
|
</DrawerContent>
|
||||||
</Drawer>
|
</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>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -27,10 +27,7 @@ export function ReceiveCard({
|
|||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
{/* Title */}
|
{/* Title */}
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<h2 className="text-3xl font-bold text-foreground">
|
<p className="text-base text-muted-foreground mt-2">
|
||||||
Receive
|
|
||||||
</h2>
|
|
||||||
<p className="!text-xl text-muted-foreground mt-2">
|
|
||||||
{mode === 'tokens'
|
{mode === 'tokens'
|
||||||
? 'Enter Cashu token to redeem'
|
? 'Enter Cashu token to redeem'
|
||||||
: 'Deposit funds with Lightning'
|
: 'Deposit funds with Lightning'
|
||||||
@@ -58,14 +55,13 @@ export function ReceiveCard({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
disabled={!activeMintUrl}
|
disabled={!activeMintUrl}
|
||||||
autoFocus
|
className="w-full h-16 !text-base text-center border bg-background focus:ring-2 focus:ring-ring focus:ring-offset-2"
|
||||||
className="w-full h-16 !text-xl text-center border-0 bg-transparent focus:ring-0 focus:ring-offset-0"
|
|
||||||
/>
|
/>
|
||||||
<div className="flex justify-center mt-4">
|
<div className="flex justify-center mt-4">
|
||||||
<Button
|
<Button
|
||||||
onClick={onReceive}
|
onClick={onReceive}
|
||||||
disabled={!tokenInput.trim() || !activeMintUrl || isLoading}
|
disabled={!tokenInput.trim() || !activeMintUrl || isLoading}
|
||||||
className="h-12 px-8 rounded-full"
|
className="h-12 px-12 rounded-full"
|
||||||
size="lg"
|
size="lg"
|
||||||
>
|
>
|
||||||
<Download className="h-5 w-5" />
|
<Download className="h-5 w-5" />
|
||||||
@@ -92,14 +88,13 @@ export function ReceiveCard({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
disabled={!activeMintUrl}
|
disabled={!activeMintUrl}
|
||||||
autoFocus
|
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]"
|
||||||
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]"
|
|
||||||
/>
|
/>
|
||||||
<div className="flex justify-center mt-4">
|
<div className="flex justify-center mt-4">
|
||||||
<Button
|
<Button
|
||||||
onClick={onReceive}
|
onClick={onReceive}
|
||||||
disabled={!quoteAmount || !activeMintUrl || isLoading}
|
disabled={!quoteAmount || !activeMintUrl || isLoading}
|
||||||
className="h-12 px-8 rounded-full"
|
className="h-12 px-12 rounded-full"
|
||||||
size="lg"
|
size="lg"
|
||||||
>
|
>
|
||||||
<Zap className="h-5 w-5" />
|
<Zap className="h-5 w-5" />
|
||||||
|
|||||||
@@ -41,10 +41,7 @@ export function SendCard({
|
|||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
{/* Title */}
|
{/* Title */}
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<h2 className="text-3xl font-bold text-foreground">
|
<p className="text-base text-muted-foreground mt-2">
|
||||||
Send
|
|
||||||
</h2>
|
|
||||||
<p className="!text-xl text-muted-foreground mt-2">
|
|
||||||
{mode === 'tokens'
|
{mode === 'tokens'
|
||||||
? 'Generate Cashu token to send'
|
? 'Generate Cashu token to send'
|
||||||
: pendingLightningAddress
|
: pendingLightningAddress
|
||||||
@@ -80,14 +77,13 @@ export function SendCard({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
disabled={!activeMintUrl}
|
disabled={!activeMintUrl}
|
||||||
autoFocus
|
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]"
|
||||||
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]"
|
|
||||||
/>
|
/>
|
||||||
<div className="flex justify-center mt-4">
|
<div className="flex justify-center mt-4">
|
||||||
<Button
|
<Button
|
||||||
onClick={onSend}
|
onClick={onSend}
|
||||||
disabled={!sendAmount || !activeMintUrl || isLoading}
|
disabled={!sendAmount || !activeMintUrl || isLoading}
|
||||||
className="h-12 px-8 rounded-full"
|
className="h-12 px-12 rounded-full"
|
||||||
size="lg"
|
size="lg"
|
||||||
>
|
>
|
||||||
<Send className="h-5 w-5" />
|
<Send className="h-5 w-5" />
|
||||||
@@ -115,15 +111,14 @@ export function SendCard({
|
|||||||
onSend();
|
onSend();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
autoFocus
|
|
||||||
disabled={!activeMintUrl}
|
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">
|
<div className="flex justify-center gap-2 mt-4">
|
||||||
<Button
|
<Button
|
||||||
onClick={onSend}
|
onClick={onSend}
|
||||||
disabled={!lightningAddressAmount || !activeMintUrl || isResolvingAddress || isLoading}
|
disabled={!lightningAddressAmount || !activeMintUrl || isResolvingAddress || isLoading}
|
||||||
className="h-12 px-8 rounded-full"
|
className="h-12 px-12 rounded-full"
|
||||||
size="lg"
|
size="lg"
|
||||||
>
|
>
|
||||||
{isResolvingAddress ? (
|
{isResolvingAddress ? (
|
||||||
@@ -168,14 +163,13 @@ export function SendCard({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
disabled={!activeMintUrl}
|
disabled={!activeMintUrl}
|
||||||
autoFocus
|
className="w-full h-16 !text-base text-center border bg-background focus:ring-2 focus:ring-ring focus:ring-offset-2"
|
||||||
className="w-full h-16 !text-xl text-center border-0 bg-transparent focus:ring-0 focus:ring-offset-0"
|
|
||||||
/>
|
/>
|
||||||
<div className="flex justify-center mt-4">
|
<div className="flex justify-center mt-4">
|
||||||
<Button
|
<Button
|
||||||
onClick={onSend}
|
onClick={onSend}
|
||||||
disabled={(!lightningInvoice.trim() && !lightningAddressInput.trim()) || !activeMintUrl || isLoading}
|
disabled={(!lightningInvoice.trim() && !lightningAddressInput.trim()) || !activeMintUrl || isLoading}
|
||||||
className="h-12 px-8 rounded-full"
|
className="h-12 px-12 rounded-full"
|
||||||
size="lg"
|
size="lg"
|
||||||
>
|
>
|
||||||
<Zap className="h-5 w-5" />
|
<Zap className="h-5 w-5" />
|
||||||
|
|||||||
@@ -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';
|
import type { HistoryEntry } from 'coco-cashu-core';
|
||||||
|
|
||||||
interface TransactionHistoryProps {
|
interface TransactionHistoryProps {
|
||||||
entries: HistoryEntry[];
|
entries: HistoryEntry[];
|
||||||
isLoading: boolean;
|
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)
|
// Icon indicating transaction type (Lightning vs Cashu)
|
||||||
const getTransactionTypeIcon = (type: string) => {
|
const getTransactionTypeIcon = (type: string) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -50,80 +48,63 @@ export function TransactionHistory({ entries, isLoading, isExpanded, setIsExpand
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (entries.length === 0 && !isLoading) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mt-6">
|
<div className="space-y-2">
|
||||||
{/* Collapsible Section Header */}
|
{isLoading ? (
|
||||||
<button
|
<div className="flex items-center justify-center py-8">
|
||||||
onClick={() => setIsExpanded(!isExpanded)}
|
<Loader2 className="h-6 w-6 animate-spin mr-2" />
|
||||||
className="w-full py-2 px-4 flex justify-center border-t border-muted hover:bg-muted/30 transition-colors"
|
<span>Loading history...</span>
|
||||||
>
|
</div>
|
||||||
{isExpanded ? (
|
) : entries.length === 0 ? (
|
||||||
<ChevronUp className="h-5 w-5 text-muted-foreground" />
|
<div className="text-center py-8 text-muted-foreground">
|
||||||
) : (
|
No transactions yet
|
||||||
<ChevronDown className="h-5 w-5 text-muted-foreground" />
|
</div>
|
||||||
)}
|
) : (
|
||||||
</button>
|
<>
|
||||||
|
{entries.map((entry) => (
|
||||||
{/* Transactions List - Only shown when expanded */}
|
<div
|
||||||
{isExpanded && (
|
key={entry.id}
|
||||||
<div className="mt-4 space-y-2">
|
className="rounded-lg p-4 hover:bg-muted/50 transition-colors"
|
||||||
{isLoading ? (
|
>
|
||||||
<div className="flex items-center justify-center py-8">
|
<div className="flex items-start justify-between">
|
||||||
<Loader2 className="h-6 w-6 animate-spin mr-2" />
|
<div className="flex items-start gap-3 flex-1">
|
||||||
<span>Loading history...</span>
|
<div className="mt-1">
|
||||||
</div>
|
{getTransactionTypeIcon(entry.type)}
|
||||||
) : (
|
</div>
|
||||||
<>
|
<div className="flex-1 min-w-0">
|
||||||
{entries.map((entry) => (
|
<div className="flex items-center gap-2 flex-wrap">
|
||||||
<div
|
<span className="font-medium">
|
||||||
key={entry.id}
|
{getHistoryLabel(entry.type)}
|
||||||
className="rounded-lg p-4 hover:bg-muted/50 transition-colors"
|
</span>
|
||||||
>
|
|
||||||
<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>
|
</div>
|
||||||
<div className="text-right ml-4 flex items-start gap-2">
|
<div className="text-sm text-muted-foreground mt-1">
|
||||||
<div>
|
{new URL(entry.mintUrl).hostname}
|
||||||
<div className="font-semibold">
|
</div>
|
||||||
{entry.type === 'send' || entry.type === 'melt' ? '-' : '+'}
|
<div className="text-xs text-muted-foreground mt-1">
|
||||||
{entry.amount.toLocaleString()} {entry.unit}
|
{new Date(entry.createdAt).toLocaleString()}
|
||||||
</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>
|
||||||
</div>
|
</div>
|
||||||
))}
|
<div className="text-right ml-4 flex items-start gap-2">
|
||||||
</>
|
<div>
|
||||||
)}
|
<div className="font-semibold">
|
||||||
</div>
|
{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>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user