Skip to content

Commit e95b7bc

Browse files
authored
Merge pull request #158 from Majormaxx/41-debounce-transaction-search
Debounce search input in transactions page
2 parents 89edea3 + 673d028 commit e95b7bc

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

app/(merchant)/transactions/page.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { useState, memo, useMemo } from 'react';
4+
import { useDebounceValue } from 'usehooks-ts';
45
import { Card, CardContent } from '@/components/ui/card';
56
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';
67
import { Input } from '@/components/ui/input';
@@ -96,16 +97,17 @@ const TransactionCard = memo(function TransactionCard({ tx, onClick }: Transacti
9697

9798
export default function TransactionsPage() {
9899
const [searchTerm, setSearchTerm] = useState('');
100+
const debouncedSearch = useDebounceValue(searchTerm, 300);
99101
const [filterCount] = useState(0);
100102
const [selectedTx, setSelectedTx] = useState<Transaction | null>(null);
101103
const isOnline = useOfflineStore((s) => s.isOnline);
102104

103105
const filteredTransactions = useMemo(() =>
104106
mockTransactions.filter(tx =>
105-
tx.txHash.toLowerCase().includes(searchTerm.toLowerCase()) ||
106-
tx.payerAddress.toLowerCase().includes(searchTerm.toLowerCase())
107+
tx.txHash.toLowerCase().includes(debouncedSearch.toLowerCase()) ||
108+
tx.payerAddress.toLowerCase().includes(debouncedSearch.toLowerCase())
107109
),
108-
[searchTerm]
110+
[debouncedSearch]
109111
);
110112

111113
return (

0 commit comments

Comments
 (0)