diff --git a/src/components/WalletButton.tsx b/src/components/WalletButton.tsx index 06b82d3..69f9a98 100644 --- a/src/components/WalletButton.tsx +++ b/src/components/WalletButton.tsx @@ -1,13 +1,22 @@ import { useState } from "react"; -import { Wallet, Zap } from "lucide-react"; +import { Wallet, Zap, X } from "lucide-react"; import { useGrimoire } from "@/core/state"; import { Button } from "@/components/ui/button"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; import ConnectWalletDialog from "@/components/ConnectWalletDialog"; +import { toast } from "sonner"; export default function WalletButton() { - const { state } = useGrimoire(); + const { state, disconnectNWC } = useGrimoire(); const nwcConnection = state.nwcConnection; const [showConnectWallet, setShowConnectWallet] = useState(false); + const [showWalletInfo, setShowWalletInfo] = useState(false); function formatBalance(millisats?: number): string { if (millisats === undefined) return "—"; @@ -15,6 +24,20 @@ export default function WalletButton() { return sats.toLocaleString(); } + function handleDisconnect() { + disconnectNWC(); + setShowWalletInfo(false); + toast.success("Wallet disconnected"); + } + + function handleClick() { + if (nwcConnection) { + setShowWalletInfo(true); + } else { + setShowConnectWallet(true); + } + } + return ( <> + {/* Wallet Info Dialog */} + {nwcConnection && ( + + + + Wallet Info + + Connected Lightning wallet details + + + +
+ {/* Balance */} +
+ Balance: + + {formatBalance(nwcConnection.balance)} + +
+ + {/* Wallet Alias */} + {nwcConnection.info?.alias && ( +
+ Wallet: + + {nwcConnection.info.alias} + +
+ )} + + {/* Lightning Address */} + {nwcConnection.lud16 && ( +
+ + Address: + + + {nwcConnection.lud16} + +
+ )} + + {/* Supported Methods */} + {nwcConnection.info?.methods && + nwcConnection.info.methods.length > 0 && ( +
+ + Supported Methods: + +
+ {nwcConnection.info.methods.map((method) => ( + + {method} + + ))} +
+
+ )} + + {/* Relays */} +
+ Relays: +
+ {nwcConnection.relays.map((relay) => ( +
+ {relay} +
+ ))} +
+
+ + {/* Disconnect Button */} + +
+
+
+ )} + + {/* Wallet Button */} {nwcConnection ? ( ) : (