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