"use client"; import { useState } from "react"; import Link from "next/link"; import { ManualCheckCapture } from "@/components/ManualCheckCapture"; import { StatementIntake } from "@/components/StatementIntake"; import { useCan } from "@/lib/abilities"; /** * The daily capture screen (the legacy "Editor"), with two ways in: * * - **manual** — key each customer's receipt against one check by hand. * - **auto** — scan the stack of paper bills and let OCR propose customer and * amount for every page, which a human still confirms. * * Both end in the same place: charges on the customer's ledger, posted against * one check. They are modes of one screen rather than two menu entries because * it is one job — staff pick the mode by what's on the desk that morning, a * stack of bills or a keyboard. * * `/estado-cuenta/lote` opens on manual, `/recibos` opens on auto; both render * this component, so an old bookmark still lands on the right tab. */ export type CaptureMode = "manual" | "auto"; const MODE_HINT: Record = { manual: "Captura los recibos de varios clientes contra un mismo cheque y concilia el total antes de guardar.", auto: "Escanea los recibos del mes y el sistema propone cliente e importe para cada página. Nada se registra sin tu confirmación.", }; export function Captura({ initialMode = "manual" }: { initialMode?: CaptureMode }) { const canCapture = useCan("ledger:create"); const canIngest = useCan("statement:ingest"); // Gating is cosmetic (the API enforces every write), but a user who only has // one of the two abilities should land on the mode they can actually use. const modes: { key: CaptureMode; label: string }[] = [ ...(canCapture ? [{ key: "manual" as const, label: "Captura manual" }] : []), ...(canIngest ? [{ key: "auto" as const, label: "Captura automática (OCR)" }] : []), ]; const [mode, setMode] = useState( modes.some((m) => m.key === initialMode) ? initialMode : (modes[0]?.key ?? "manual"), ); if (modes.length === 0) { return (
No tienes permiso para capturar movimientos.
); } return ( <>

Captura

{MODE_HINT[mode]}

Volver a estado de cuenta
{modes.length > 1 && (
{modes.map((m) => ( ))}
)} {mode === "manual" ? : } ); }