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
@@ -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>
|
||||
</>
|
||||
|
||||
Reference in new issue
Block a user