From aed967dc442da3a371740ddddf7c2f6dfef6db7c Mon Sep 17 00:00:00 2001 From: 9qeklajc Date: Mon, 16 Mar 2026 21:00:53 +0100 Subject: [PATCH] update ui --- ui/app/transactions/page.tsx | 211 ++++++++++++++++++++++++++--------- 1 file changed, 156 insertions(+), 55 deletions(-) diff --git a/ui/app/transactions/page.tsx b/ui/app/transactions/page.tsx index e07eef52..07dc0e2a 100644 --- a/ui/app/transactions/page.tsx +++ b/ui/app/transactions/page.tsx @@ -1,12 +1,19 @@ 'use client'; -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { useQuery } from '@tanstack/react-query'; import { AppPageShell } from '@/components/app-page-shell'; import { PageHeader } from '@/components/page-header'; -import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; +import { Label } from '@/components/ui/label'; import { Select, SelectContent, @@ -25,6 +32,13 @@ import { } from '@/components/ui/table'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Skeleton } from '@/components/ui/skeleton'; +import { + Empty, + EmptyDescription, + EmptyHeader, + EmptyMedia, + EmptyTitle, +} from '@/components/ui/empty'; import { RefreshCw, Search, @@ -32,17 +46,41 @@ import { ArrowUpRight, Copy, Check, + Receipt, } from 'lucide-react'; import { AdminService, type Transaction } from '@/lib/api/services/admin'; import { format } from 'date-fns'; import { toast } from 'sonner'; +const STORAGE_KEY = 'routstr-transaction-filters'; + export default function TransactionsPage() { const [search, setSearch] = useState(''); const [type, setType] = useState('all'); const [status, setStatus] = useState('all'); const [copiedId, setCopiedId] = useState(null); + // Load filters from localStorage on mount + useEffect(() => { + const saved = localStorage.getItem(STORAGE_KEY); + if (saved) { + try { + const parsed = JSON.parse(saved); + if (parsed.search) setSearch(parsed.search); + if (parsed.type) setType(parsed.type); + if (parsed.status) setStatus(parsed.status); + } catch (e) { + console.error('Failed to load filters from localStorage', e); + } + } + }, []); + + // Save filters to localStorage whenever they change + useEffect(() => { + const filters = { search, type, status }; + localStorage.setItem(STORAGE_KEY, JSON.stringify(filters)); + }, [search, type, status]); + const { data, isLoading, refetch, isRefetching } = useQuery({ queryKey: ['transactions', type, status, search], queryFn: () => @@ -54,6 +92,12 @@ export default function TransactionsPage() { ), }); + const handleClearFilters = () => { + setSearch(''); + setType('all'); + setStatus('all'); + }; + const copyToClipboard = (text: string, id: string) => { navigator.clipboard.writeText(text); setCopiedId(id); @@ -90,11 +134,22 @@ export default function TransactionsPage() { ); }; + const hasActiveFilters = + type !== 'all' || status !== 'all' || Boolean(search); + + const activeFilterDescription = [ + type !== 'all' ? `type ${type === 'in' ? 'incoming' : 'outgoing'}` : null, + status !== 'all' ? `status ${status}` : null, + search ? `search "${search}"` : null, + ] + .filter(Boolean) + .join(' • '); + return ( - +
-
-
-
- - setSearch(e.target.value)} - /> + + + Filters + + Filter transactions by type, status, or search text + + + +
+
+ +
+ + setSearch(e.target.value)} + /> +
+
+
+ + +
+
+ + +
+
+ +
-
- - -
+ + - Transaction History +
+ Transaction History + {data && ( + + {data.transactions.length} entries + + )} +
+ {hasActiveFilters && ( + + Showing transactions filtered by {activeFilterDescription} + + )}
- + {isLoading ? (
- {Array.from({ length: 5 }).map((_, i) => ( - + {Array.from({ length: 8 }).map((_, index) => ( + ))}
- ) : ( - + ) : data?.transactions && data.transactions.length > 0 ? ( + @@ -172,7 +269,7 @@ export default function TransactionsPage() { - {data?.transactions.map((tx) => ( + {data.transactions.map((tx) => (
@@ -213,7 +310,9 @@ export default function TransactionsPage() {
) : ( - + + — + )}
@@ -243,19 +342,21 @@ export default function TransactionsPage() {
))} - {data?.transactions.length === 0 && ( - - - No transactions found - - - )}
+ ) : ( + + + + + + No transactions found + + Try adjusting your filters or check back later. + + + )}