import { useState } from 'react'; import { useSeoMeta } from '@unhead/react'; import { Link } from 'react-router-dom'; import { PageHeader } from '@/components/PageHeader'; import { WalletModal } from '@/components/WalletModal'; import { Badge } from '@/components/ui/badge'; import { useWallet } from '@/hooks/useWallet'; import { useNWC } from '@/hooks/useNWCContext'; import { useCurrentUser } from '@/hooks/useCurrentUser'; import { useCashu } from '@/hooks/wallet/useCashu'; import { useTranslation } from '@/contexts/language'; import { LoginArea } from '@/components/auth/LoginArea'; import { CashuWalletCard } from '@/components/wallet/CashuWalletCard'; import { EscrowKeyCard } from '@/components/wallet/EscrowKeyCard'; import { EscrowSettingsCard } from '@/components/wallet/EscrowSettingsCard'; import { NwcWalletCard } from '@/components/wallet/NwcWalletCard'; import { cn } from '@/lib/utils'; import { Zap, Settings, CheckCircle, XCircle, Globe, WalletMinimal, Nut, ChevronRight, ExternalLink, ChevronDown, ChevronUp, Wallet, Coins, } from 'lucide-react'; // ─── Wallet status bar ──────────────────────────────────────────────────────── function WalletStatusBar() { const { t } = useTranslation(); const { webln } = useWallet(); const { connections } = useNWC(); const { isInitialized: hasCashu } = useCashu(); const hasNWC = connections.length > 0 && connections.some((c) => c.isConnected); const isReady = webln || hasNWC || hasCashu; return (
{/* Status pills */}
{/* Manage wallets */}
); } function StatusPill({ icon: Icon, label, active, color, activeBg, }: { icon: React.ComponentType<{ className?: string }>; label: string; active: boolean; color: string; activeBg: string; }) { return (
{label} {active ? : }
); } // ─── Get a wallet (collapsible) ─────────────────────────────────────────────── function GetAWallet() { const { t } = useTranslation(); const [open, setOpen] = useState(false); const wallets = [ { name: 'Minibits', desc: t('walletUi.page.walletMinibits'), url: 'https://www.minibits.cash', color: 'text-orange-400' }, { name: 'Alby', desc: t('walletUi.page.walletAlby'), url: 'https://getalby.com', color: 'text-yellow-400' }, { name: 'Zeus', desc: t('walletUi.page.walletZeus'), url: 'https://zeusln.com', color: 'text-blue-400' }, { name: 'Coinos', desc: t('walletUi.page.walletCoinos'), url: 'https://coinos.io', color: 'text-green-400' }, ]; return (
{open && (
{wallets.map((w) => (

{w.name}

{w.desc}

))}
{t('walletUi.page.learnPlanB')}
)}
); } // ─── What are zaps (collapsible, hidden once wallet connected) ──────────────── function WhatAreZaps({ walletConnected }: { walletConnected: boolean }) { const { t } = useTranslation(); const [open, setOpen] = useState(!walletConnected); if (walletConnected && !open) { return ( ); } return (
{open && (

{t('walletUi.page.zapsDesc')}

{[ { emoji: '⚡', title: t('walletUi.page.instant'), desc: t('walletUi.page.instantDesc') }, { emoji: '🔐', title: t('walletUi.page.flexible'), desc: t('walletUi.page.flexibleDesc') }, { emoji: '🥜', title: t('walletUi.page.private'), desc: t('walletUi.page.privateDesc') }, { emoji: '💜', title: t('walletUi.page.direct'), desc: t('walletUi.page.directDesc') }, ].map((item) => (
{item.emoji}

{item.title}

{item.desc}

))}
)}
); } // ─── Not logged in ──────────────────────────────────────────────────────────── function NotLoggedIn() { const { t } = useTranslation(); return (

{t('walletUi.page.loginRequired')}

{t('walletUi.page.loginRequiredDesc')}

); } // ─── Page ───────────────────────────────────────────────────────────────────── export default function WalletPage() { const { t } = useTranslation(); useSeoMeta({ title: t('seoUi.walletTitle'), description: t('seoUi.walletDesc'), }); const { user } = useCurrentUser(); const { webln } = useWallet(); const { connections } = useNWC(); const { isInitialized: hasCashu } = useCashu(); const hasNWC = connections.length > 0 && connections.some((c) => c.isConnected); const walletConnected = !!(webln || hasNWC || hasCashu); return ( <>
{user ? (
{/* Status bar + manage — compact single row */} {/* Connected Lightning wallet (NIP-47) — balance / receive / send */} {/* Cashu wallet — native app, self-custodial ecash */} {t('walletUi.page.browseMints')} {/* Get a wallet — collapsed by default */} {/* What are zaps — auto-collapses once wallet connected */}
) : ( )}
); }