mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 08:23:35 +00:00
transaction history formatting
This commit is contained in:
1 parent
fd684a40a8
commit
2569f0dd0d
1 file changed
+37
-14
@@ -1,7 +1,7 @@
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Loader2, History, ArrowUpRight, ArrowDownLeft, Zap, ChevronDown, ChevronUp } from 'lucide-react';
|
||||
import { Loader2, History, ArrowUpRight, ArrowDownLeft, Zap, ChevronDown, ChevronUp, Coins } from 'lucide-react';
|
||||
import type { HistoryEntry } from '@/hooks/useCashu';
|
||||
|
||||
interface TransactionHistoryProps {
|
||||
@@ -12,27 +12,40 @@ interface TransactionHistoryProps {
|
||||
}
|
||||
|
||||
export function TransactionHistory({ entries, isLoading, isExpanded, setIsExpanded }: TransactionHistoryProps) {
|
||||
const getHistoryIcon = (type: string) => {
|
||||
// Icon indicating transaction type (Lightning vs Cashu)
|
||||
const getTransactionTypeIcon = (type: string) => {
|
||||
switch (type) {
|
||||
case 'mint':
|
||||
return <ArrowDownLeft className="h-4 w-4 text-green-500" />;
|
||||
case 'melt':
|
||||
return <Zap className="h-4 w-4 text-yellow-500" />;
|
||||
return <Zap className="h-4 w-4" />;
|
||||
case 'send':
|
||||
return <ArrowUpRight className="h-4 w-4 text-red-500" />;
|
||||
case 'receive':
|
||||
return <ArrowDownLeft className="h-4 w-4 text-green-500" />;
|
||||
return <Coins className="h-4 w-4" />;
|
||||
default:
|
||||
return <History className="h-4 w-4" />;
|
||||
}
|
||||
};
|
||||
|
||||
// Arrow indicating direction (next to amount)
|
||||
const getDirectionIcon = (type: string) => {
|
||||
switch (type) {
|
||||
case 'mint':
|
||||
case 'receive':
|
||||
return <ArrowDownLeft className="h-4 w-4 text-green-500" />;
|
||||
case 'melt':
|
||||
case 'send':
|
||||
return <ArrowUpRight className="h-4 w-4 text-red-500" />;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const getHistoryLabel = (type: string) => {
|
||||
switch (type) {
|
||||
case 'mint':
|
||||
return 'Mint (Lightning → Tokens)';
|
||||
return 'Mint Tokens';
|
||||
case 'melt':
|
||||
return 'Melt (Tokens → Lightning)';
|
||||
return 'Melt Tokens';
|
||||
case 'send':
|
||||
return 'Send Tokens';
|
||||
case 'receive':
|
||||
@@ -109,14 +122,14 @@ export function TransactionHistory({ entries, isLoading, isExpanded, setIsExpand
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex items-start gap-3 flex-1">
|
||||
<div className="mt-1">
|
||||
{getHistoryIcon(entry.type)}
|
||||
{getTransactionTypeIcon(entry.type)}
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<span className="font-medium">
|
||||
{getHistoryLabel(entry.type)}
|
||||
</span>
|
||||
{entry.state && (
|
||||
{entry.state && entry.type !== 'mint' && entry.type !== 'melt' && (
|
||||
<Badge
|
||||
variant="secondary"
|
||||
className={`${getHistoryStateColor(entry.state)} text-white text-xs`}
|
||||
@@ -133,10 +146,20 @@ export function TransactionHistory({ entries, isLoading, isExpanded, setIsExpand
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right ml-4">
|
||||
<div className="font-semibold">
|
||||
{entry.type === 'send' || entry.type === 'melt' ? '-' : '+'}
|
||||
{entry.amount.toLocaleString()} {entry.unit}
|
||||
<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="mt-1">
|
||||
{getDirectionIcon(entry.type)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user