From 0d6a47d5797880450ef2f9c511e6cfcb46426da7 Mon Sep 17 00:00:00 2001 From: Peircharla Bindhu madhavi Date: Tue, 2 Jun 2026 00:55:53 +0530 Subject: [PATCH] feat: add search and diagnosis filter to history page (#21) --- src/app/history/page.tsx | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/app/history/page.tsx b/src/app/history/page.tsx index 82ca0ad..8dd4ddf 100644 --- a/src/app/history/page.tsx +++ b/src/app/history/page.tsx @@ -15,6 +15,14 @@ interface Record { export default function HistoryPage() { const [records, setRecords] = useState([]); const [loading, setLoading] = useState(true); + const [search, setSearch] = useState(""); + const [diagnosisFilter, setDiagnosisFilter] = useState("All"); + + const filteredRecords = records.filter((record) => { + const matchesSearch = record.filename.toLowerCase().includes(search.toLowerCase()); + const matchesDiagnosis = diagnosisFilter === "All" || record.diagnosis === diagnosisFilter; + return matchesSearch && matchesDiagnosis; + }); useEffect(() => { async function fetchHistory() { @@ -47,6 +55,25 @@ export default function HistoryPage() { +
+ setSearch(e.target.value)} + className="w-full sm:w-80 px-4 py-2.5 bg-white border-2 border-slate-100 rounded-xl focus:outline-none focus:border-accent-primary/30 text-slate-800 font-bold placeholder:text-slate-300 text-sm" + /> + +
+
{loading ? (
@@ -57,6 +84,10 @@ export default function HistoryPage() {

No records found in the database.

Perform your first scan →
+ ) : filteredRecords.length === 0 ? ( +
+

No records match your search.

+
) : (
@@ -70,7 +101,7 @@ export default function HistoryPage() { - {records.map((record) => ( + {filteredRecords.map((record) => (
{new Date(record.createdAt).toLocaleString()}