KarthiEz commited on
Commit
7a7fe76
·
verified ·
1 Parent(s): 28f07af

Update frontend/src/App.tsx

Browse files
Files changed (1) hide show
  1. frontend/src/App.tsx +34 -0
frontend/src/App.tsx CHANGED
@@ -350,6 +350,30 @@ export default function App() {
350
  };
351
  }, [page, selectedHistoryId]);
352
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
  const stepState = useMemo(() => {
354
  const upload: StepState = stage === "upload" ? "active" : "done";
355
  // Keep the 3-step bar, but make it unambiguous:
@@ -1556,6 +1580,16 @@ export default function App() {
1556
  >
1557
  Export All
1558
  </button>
 
 
 
 
 
 
 
 
 
 
1559
  </div>
1560
 
1561
  <div className="grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-4">
 
350
  };
351
  }, [page, selectedHistoryId]);
352
 
353
+ // Clear all history
354
+ async function onClearHistory() {
355
+ if (!window.confirm("Are you sure you want to clear all history records? This action cannot be undone.")) {
356
+ return;
357
+ }
358
+ setHistoryError(null);
359
+ setHistoryLoading(true);
360
+ try {
361
+ await clearDb();
362
+ setHistoryItems([]);
363
+ setSelectedHistoryId(null);
364
+ setHistoryDetail(null);
365
+ setHistoryDetailsOpen(false);
366
+ setHistorySearch("");
367
+ setHistoryStatusFilter("");
368
+ setToast("All history records cleared");
369
+ } catch (e: any) {
370
+ setHistoryError(e?.message || String(e));
371
+ setToast(null);
372
+ } finally {
373
+ setHistoryLoading(false);
374
+ }
375
+ }
376
+
377
  const stepState = useMemo(() => {
378
  const upload: StepState = stage === "upload" ? "active" : "done";
379
  // Keep the 3-step bar, but make it unambiguous:
 
1580
  >
1581
  Export All
1582
  </button>
1583
+
1584
+ <button
1585
+ type="button"
1586
+ className="rounded-xl border border-rose-500/30 bg-rose-50 px-4 py-2.5 text-sm font-bold text-rose-700 shadow-sm hover:bg-rose-100 disabled:opacity-40"
1587
+ onClick={onClearHistory}
1588
+ disabled={historyLoading || historyItems.length === 0}
1589
+ title="Clear all history records from database"
1590
+ >
1591
+ Clear All History
1592
+ </button>
1593
  </div>
1594
 
1595
  <div className="grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-4">