mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-06 00:37:23 +00:00
updated transactions look
This commit is contained in:
1 parent
6162217ce9
commit
56bdebff5d
1 file changed
+68
-86
@@ -1,5 +1,3 @@
|
|||||||
import { Button } from '@/components/ui/button';
|
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
|
||||||
import { Loader2, History, ArrowUpRight, ArrowDownLeft, Zap, ChevronDown, ChevronUp, Coins } from 'lucide-react';
|
import { Loader2, History, ArrowUpRight, ArrowDownLeft, Zap, ChevronDown, ChevronUp, Coins } from 'lucide-react';
|
||||||
import type { HistoryEntry } from 'coco-cashu-core';
|
import type { HistoryEntry } from 'coco-cashu-core';
|
||||||
|
|
||||||
@@ -52,97 +50,81 @@ export function TransactionHistory({ entries, isLoading, isExpanded, setIsExpand
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (entries.length === 0 && !isLoading) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="mt-6 border-0 shadow-none">
|
<div className="mt-6">
|
||||||
<CardHeader>
|
{/* Collapsible Section Header */}
|
||||||
<CardTitle className="flex items-center justify-between">
|
<button
|
||||||
<div className="flex items-center">
|
onClick={() => setIsExpanded(!isExpanded)}
|
||||||
<History className="h-5 w-5 mr-2" />
|
className="w-full py-2 px-4 flex justify-center border-t border-muted hover:bg-muted/30 transition-colors"
|
||||||
Transaction History
|
>
|
||||||
</div>
|
{isExpanded ? (
|
||||||
{entries.length > 3 && (
|
<ChevronUp className="h-5 w-5 text-muted-foreground" />
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => setIsExpanded(!isExpanded)}
|
|
||||||
className="gap-1"
|
|
||||||
>
|
|
||||||
{isExpanded ? (
|
|
||||||
<>
|
|
||||||
<ChevronUp className="h-4 w-4" />
|
|
||||||
Hide
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<ChevronDown className="h-4 w-4" />
|
|
||||||
Show
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</CardTitle>
|
|
||||||
<CardDescription>
|
|
||||||
View your recent transactions
|
|
||||||
</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
{isLoading ? (
|
|
||||||
<div className="flex items-center justify-center py-8">
|
|
||||||
<Loader2 className="h-6 w-6 animate-spin mr-2" />
|
|
||||||
<span>Loading history...</span>
|
|
||||||
</div>
|
|
||||||
) : entries.length === 0 ? (
|
|
||||||
<div className="text-center py-8 text-muted-foreground">
|
|
||||||
No transaction history yet
|
|
||||||
</div>
|
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-2">
|
<ChevronDown className="h-5 w-5 text-muted-foreground" />
|
||||||
{(isExpanded ? entries : entries.slice(0, 3)).map((entry) => (
|
)}
|
||||||
<div
|
</button>
|
||||||
key={entry.id}
|
|
||||||
className="rounded-lg p-4 hover:bg-muted/50 transition-colors"
|
{/* Transactions List - Only shown when expanded */}
|
||||||
>
|
{isExpanded && (
|
||||||
<div className="flex items-start justify-between">
|
<div className="mt-4 space-y-2">
|
||||||
<div className="flex items-start gap-3 flex-1">
|
{isLoading ? (
|
||||||
<div className="mt-1">
|
<div className="flex items-center justify-center py-8">
|
||||||
{getTransactionTypeIcon(entry.type)}
|
<Loader2 className="h-6 w-6 animate-spin mr-2" />
|
||||||
</div>
|
<span>Loading history...</span>
|
||||||
<div className="flex-1 min-w-0">
|
</div>
|
||||||
<div className="flex items-center gap-2 flex-wrap">
|
) : (
|
||||||
<span className="font-medium">
|
<>
|
||||||
{getHistoryLabel(entry.type)}
|
{entries.map((entry) => (
|
||||||
</span>
|
<div
|
||||||
|
key={entry.id}
|
||||||
|
className="rounded-lg p-4 hover:bg-muted/50 transition-colors"
|
||||||
|
>
|
||||||
|
<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>
|
||||||
<div className="text-sm text-muted-foreground mt-1">
|
<div className="flex-1 min-w-0">
|
||||||
{new URL(entry.mintUrl).hostname}
|
<div className="flex items-center gap-2 flex-wrap">
|
||||||
</div>
|
<span className="font-medium">
|
||||||
<div className="text-xs text-muted-foreground mt-1">
|
{getHistoryLabel(entry.type)}
|
||||||
{new Date(entry.createdAt).toLocaleString()}
|
</span>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="text-right ml-4 flex items-start gap-2">
|
|
||||||
<div>
|
|
||||||
<div className="font-semibold">
|
|
||||||
{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="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="mt-1">
|
<div className="text-right ml-4 flex items-start gap-2">
|
||||||
{getDirectionIcon(entry.type)}
|
<div>
|
||||||
|
<div className="font-semibold">
|
||||||
|
{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>
|
</div>
|
||||||
</div>
|
))}
|
||||||
))}
|
</>
|
||||||
</div>
|
)}
|
||||||
)}
|
</div>
|
||||||
</CardContent>
|
)}
|
||||||
</Card>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user