diff --git a/src/components/auth/LoginIcon.tsx b/src/components/auth/LoginIcon.tsx new file mode 100644 index 0000000..5c0d918 --- /dev/null +++ b/src/components/auth/LoginIcon.tsx @@ -0,0 +1,50 @@ +import { useState } from 'react'; +import { User, UserPlus } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import LoginDialog from './LoginDialog'; +import SignupDialog from './SignupDialog'; +import { useLoggedInAccounts } from '@/hooks/useLoggedInAccounts'; +import { AccountSwitcher } from './AccountSwitcher'; + +export function LoginIcon() { + const { currentUser } = useLoggedInAccounts(); + const [loginDialogOpen, setLoginDialogOpen] = useState(false); + const [signupDialogOpen, setSignupDialogOpen] = useState(false); + + const handleLogin = () => { + setLoginDialogOpen(false); + setSignupDialogOpen(false); + }; + + if (currentUser) { + return ( + setLoginDialogOpen(true)} /> + ); + } + + return ( + <> + + + setLoginDialogOpen(false)} + onLogin={handleLogin} + onSignup={() => setSignupDialogOpen(true)} + /> + + setSignupDialogOpen(false)} + /> + + ); +} diff --git a/src/components/wallet/ActionButtons.tsx b/src/components/wallet/ActionButtons.tsx index b2fa02e..31cd1ef 100644 --- a/src/components/wallet/ActionButtons.tsx +++ b/src/components/wallet/ActionButtons.tsx @@ -9,15 +9,15 @@ interface ActionButtonsProps { export function ActionButtons({ onSendClick, onReceiveClick, isLoading }: ActionButtonsProps) { return ( -
+
); diff --git a/src/components/wallet/BalanceDisplay.tsx b/src/components/wallet/BalanceDisplay.tsx index 3e0fbf1..0677a21 100644 --- a/src/components/wallet/BalanceDisplay.tsx +++ b/src/components/wallet/BalanceDisplay.tsx @@ -2,7 +2,7 @@ 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, Zap, Coins, HelpCircle, QrCode, Copy, Check, RefreshCw } from 'lucide-react'; +import { Wallet, ChevronDown, Plus, X, QrCode, Copy, Check } from 'lucide-react'; import { useState, useEffect } from 'react'; import { exchangeRateService } from '@/lib/exchangeRateService'; @@ -16,8 +16,6 @@ interface BalanceDisplayProps { balances: { [key: string]: number }; showSats: boolean; setShowSats: (showSats: boolean) => void; - mode: 'tokens' | 'lightning'; - setMode: (mode: 'tokens' | 'lightning') => void; activeMintUrl: string | null; setActiveMintUrl: (url: string | null) => void; mints: CashuMint[]; @@ -43,8 +41,6 @@ export function BalanceDisplay({ balances, showSats, setShowSats, - mode, - setMode, activeMintUrl, setActiveMintUrl, mints, @@ -73,13 +69,13 @@ export function BalanceDisplay({ const convertCurrency = (sats: number, showSats: boolean): string => { if (showSats) { - return `${sats.toLocaleString()} sats`; + return `₿${sats.toLocaleString()}`; } else if (btcUsdRate) { const btcAmount = sats / 100000000; const usd = btcAmount * btcUsdRate; return `$${usd.toFixed(2)}`; } else { - return `${sats.toLocaleString()} sats`; + return `₿${sats.toLocaleString()}`; } }; @@ -91,41 +87,35 @@ export function BalanceDisplay({ className="text-5xl font-bold tabular-nums hover:opacity-80 transition-opacity cursor-pointer" title={`Click to show in ${showSats ? 'USD' : 'sats'}`} > - {convertCurrency(totalBalance, showSats)} + + {showSats ? '₿' : '$'} + + {showSats ? totalBalance.toLocaleString() : (btcUsdRate ? `${(totalBalance / 100000000 * btcUsdRate).toFixed(2)}` : totalBalance.toLocaleString())}
- {/* Main Mode Toggle */} -
-
+ {/* Active Mint Dropdown */} +
+ {activeMintUrl && ( - -
-
- - {/* Active Mint Dropdown and Balance */} -
+ )} - @@ -143,6 +133,9 @@ export function BalanceDisplay({ >
{getCleanMintLabel(mint)} + + {convertCurrency(balances[mint.url] || 0, showSats)} +
- - {/* Help button */} - - - - - - - - - What is a Mint? - - -
-

- A mint is a server that issues and manages Cashu tokens. Think of it like a bank for digital cash. -

-

- Key features: -

-
    -
  • Issues tokens when you deposit Lightning payments
  • -
  • Redeems tokens when you receive them
  • -
  • Manages your token balance
  • -
  • Enables Lightning ↔ Cashu conversions
  • -
-

- Note: Each mint maintains its own separate balance. You can add multiple mints to diversify your holdings and swap balances between them. -

-
-
-
-
- )}
{/* Lightning Address */} @@ -233,11 +179,16 @@ export function BalanceDisplay({ 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]" + className="flex items-center gap-2 px-3 py-1.5 bg-muted hover:bg-muted/80 rounded-md border text-base font-mono transition-colors h-[34px]" title="Click to copy Lightning address" > - {npubCashUsername}@npubx.cash + {(() => { + const lightningAddress = `${npubCashUsername}@npubx.cash`; + return lightningAddress.length > 33 + ? `${lightningAddress.substring(0, 15)}...${lightningAddress.substring(lightningAddress.length - 15)}` + : lightningAddress; + })()} {lightningAddressCopied ? ( diff --git a/src/components/wallet/CashuWallet.tsx b/src/components/wallet/CashuWallet.tsx index 1adf7db..dcc1bd8 100644 --- a/src/components/wallet/CashuWallet.tsx +++ b/src/components/wallet/CashuWallet.tsx @@ -13,13 +13,14 @@ import { useHistoryManager } from '@/hooks/cashu/useHistoryManager'; import { QRModal } from '@/components/ui/qr-modal'; import { BalanceDisplay } from './BalanceDisplay'; import { ActionButtons } from './ActionButtons'; +import { ModeToggle } from './ModeToggle'; import { Drawer, DrawerContent, DrawerHeader, DrawerTitle } from '@/components/ui/drawer'; import { ReceiveCard } from './ReceiveCard'; import { SendCard } from './SendCard'; import { TransactionHistory } from './TransactionHistory'; import { ProofBreakdownModal } from './ProofBreakdownModal'; import { RemoveMintModal } from './RemoveMintModal'; -import { LoginArea } from '@/components/auth/LoginArea'; +import { LoginIcon } from '@/components/auth/LoginIcon'; export function CashuWallet() { // ============================================================================ @@ -276,11 +277,16 @@ export function CashuWallet() { return ( <> -
+
- {/* Login Area */} -
- + {/* Mode Toggle */} +
+ +
+ + {/* Login Icon */} +
+
{/* Balance Display */} @@ -289,8 +295,6 @@ export function CashuWallet() { balances={balances} showSats={showSats} setShowSats={setShowSats} - mode={mode} - setMode={setMode} activeMintUrl={activeMintUrl} setActiveMintUrl={handleSetActiveMintSync} mints={mints} @@ -410,9 +414,9 @@ export function CashuWallet() { {/* Bottom Drawer Modals */} - + - Send +
- + - Receive +
void; +} + +export function ModeToggle({ mode, setMode }: ModeToggleProps) { + const { toast } = useToast(); + + const toggleMode = () => { + const newMode = mode === 'tokens' ? 'lightning' : 'tokens'; + setMode(newMode); + + toast({ + title: `${newMode === 'tokens' ? 'Cashu' : 'Lightning'} Enabled!`, + description: newMode === 'tokens' + ? 'Send and receive with Cashu eCash' + : 'Send and receive with Lightning', + }); + }; + + return ( + + ); +} diff --git a/src/components/wallet/ReceiveCard.tsx b/src/components/wallet/ReceiveCard.tsx index faa68b5..7fc7a62 100644 --- a/src/components/wallet/ReceiveCard.tsx +++ b/src/components/wallet/ReceiveCard.tsx @@ -24,10 +24,13 @@ export function ReceiveCard({ isLoading, }: ReceiveCardProps) { return ( -
- {/* Description */} +
+ {/* Title */}
-

+

+ Receive +

+

{mode === 'tokens' ? 'Enter Cashu token to redeem' : 'Deposit funds with Lightning' @@ -54,19 +57,20 @@ export function ReceiveCard({ onReceive(); } }} - className="w-full" disabled={!activeMintUrl} autoFocus + className="w-full h-16 !text-xl text-center border-0 bg-transparent focus:ring-0 focus:ring-offset-0" /> - +

+ +
) : ( @@ -89,16 +93,18 @@ 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]" /> - +
+ +
)} diff --git a/src/components/wallet/SendCard.tsx b/src/components/wallet/SendCard.tsx index b2e6e1a..3f2dd9c 100644 --- a/src/components/wallet/SendCard.tsx +++ b/src/components/wallet/SendCard.tsx @@ -38,10 +38,13 @@ export function SendCard({ isLoading, }: SendCardProps) { return ( -
- {/* Description */} +
+ {/* Title */}
-

+

+ Send +

+

{mode === 'tokens' ? 'Generate Cashu token to send' : pendingLightningAddress @@ -51,7 +54,7 @@ export function SendCard({ {pendingLightningAddress} ) - : 'Pay Lightning invoices or addresses from balance' + : 'Pay invoices or addresses' }

@@ -78,16 +81,18 @@ 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]" /> - +
+ +
) : ( @@ -112,24 +117,19 @@ export function SendCard({ }} 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]" /> -
+
@@ -167,19 +167,20 @@ export function SendCard({ onSend(); } }} - className="w-full" disabled={!activeMintUrl} autoFocus + className="w-full h-16 !text-xl text-center border-0 bg-transparent focus:ring-0 focus:ring-offset-0" /> - +
+ +
)} diff --git a/src/hooks/cashu/useWalletTransactions.ts b/src/hooks/cashu/useWalletTransactions.ts index 5ef7a97..eae6e1f 100644 --- a/src/hooks/cashu/useWalletTransactions.ts +++ b/src/hooks/cashu/useWalletTransactions.ts @@ -163,13 +163,8 @@ export function useWalletTransactions({ qrCodeUrl, expiry: quote.expiry, }); + setShowInvoiceModal(true); - - toast({ - title: 'Lightning Invoice Created', - description: - 'Wallet will automatically claim tokens when payment is detected.', - }); setQuoteAmount(''); // Clean up any previous listener