Allow reprocessing any card, not just errored ones
The Reprocess button and dropdown item were only visible for cards with ocrStatus "error". Now they appear for any card that isn't currently processing, so users can re-run OCR on completed cards too (e.g. after changing AI settings). Made-with: Cursor
This commit is contained in:
parent
9f6e9c3c40
commit
9ea9ca741c
3 changed files with 4 additions and 4 deletions
|
|
@ -14,9 +14,9 @@ export async function POST(
|
||||||
return NextResponse.json({ error: "Card not found" }, { status: 404 });
|
return NextResponse.json({ error: "Card not found" }, { status: 404 });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card.ocrStatus !== "error") {
|
if (card.ocrStatus === "processing") {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: `Cannot reprocess card with status "${card.ocrStatus}"` },
|
{ error: "Card is already being processed" },
|
||||||
{ status: 400 }
|
{ status: 400 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@ export default function CardDetailPage() {
|
||||||
|
|
||||||
<Header title={String(card.name || "Unnamed Card")} icon={ScanLine}>
|
<Header title={String(card.name || "Unnamed Card")} icon={ScanLine}>
|
||||||
<div className="flex flex-wrap gap-2">
|
<div className="flex flex-wrap gap-2">
|
||||||
{ocrStatus === "error" && (
|
{ocrStatus !== "processing" && (
|
||||||
<Button variant="outline" size="sm" className="rounded-xl" onClick={handleReprocess} disabled={reprocessing}>
|
<Button variant="outline" size="sm" className="rounded-xl" onClick={handleReprocess} disabled={reprocessing}>
|
||||||
{reprocessing ? (
|
{reprocessing ? (
|
||||||
<><Loader2 className="mr-1 size-4 animate-spin" /> Reprocessing...</>
|
<><Loader2 className="mr-1 size-4 animate-spin" /> Reprocessing...</>
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,7 @@ export function createColumns(actions?: ColumnActions): ColumnDef<ResponseCard>[
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
)}
|
)}
|
||||||
{actions?.onReprocess &&
|
{actions?.onReprocess &&
|
||||||
row.original.ocrStatus === "error" && (
|
row.original.ocrStatus !== "processing" && (
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={() => actions.onReprocess?.(row.original)}
|
onClick={() => actions.onReprocess?.(row.original)}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue