Add reprocess action to data table row dropdown
Cards with OCR error status now show a "Reprocess" option in the row actions dropdown menu on the dashboard, triggering the existing reprocess API endpoint. Made-with: Cursor
This commit is contained in:
parent
38f4229d3b
commit
a6270a605a
2 changed files with 28 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ import {
|
|||
ArrowUpDown,
|
||||
ArrowUp,
|
||||
ArrowDown,
|
||||
RefreshCw,
|
||||
} from "lucide-react";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
|
|
@ -106,6 +107,7 @@ function getConfidenceClass(confidence: number | null): string {
|
|||
export type ColumnActions = {
|
||||
onViewDetails?: (card: ResponseCard) => void;
|
||||
onMarkReviewed?: (card: ResponseCard) => void;
|
||||
onReprocess?: (card: ResponseCard) => void;
|
||||
onDelete?: (card: ResponseCard) => void;
|
||||
};
|
||||
|
||||
|
|
@ -309,6 +311,15 @@ export function createColumns(actions?: ColumnActions): ColumnDef<ResponseCard>[
|
|||
Mark reviewed
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{actions?.onReprocess &&
|
||||
row.original.ocrStatus === "error" && (
|
||||
<DropdownMenuItem
|
||||
onClick={() => actions.onReprocess?.(row.original)}
|
||||
>
|
||||
<RefreshCw className="mr-2 size-4" />
|
||||
Reprocess
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{actions?.onDelete && (
|
||||
<DropdownMenuItem
|
||||
variant="destructive"
|
||||
|
|
|
|||
|
|
@ -190,6 +190,23 @@ export function DashboardContent() {
|
|||
toast.success("Marked as reviewed");
|
||||
fetchCards();
|
||||
},
|
||||
onReprocess: async (card) => {
|
||||
try {
|
||||
const res = await fetch(`/api/cards/${card.id}/reprocess`, {
|
||||
method: "POST",
|
||||
});
|
||||
if (!res.ok) {
|
||||
const err = await res.json();
|
||||
throw new Error(err.error || "Failed to start reprocessing");
|
||||
}
|
||||
toast.success("Reprocessing started");
|
||||
fetchCards();
|
||||
} catch (err) {
|
||||
toast.error(
|
||||
err instanceof Error ? err.message : "Failed to start reprocessing"
|
||||
);
|
||||
}
|
||||
},
|
||||
onDelete: async (card) => {
|
||||
await fetch(`/api/cards/${card.id}`, { method: "DELETE" });
|
||||
toast.success("Card deleted");
|
||||
|
|
|
|||
Loading…
Reference in a new issue