import Link from "next/link"; import { notFound } from "next/navigation"; import { getFormatter, getTranslations } from "next-intl/server"; import { ArrowLeft } from "lucide-react"; import { REPORT_EDITABLE, type ReportStatus } from "@/lib/reports/content"; import { can, ServiceError } from "@/server/services/context"; import { getMobileReportState } from "@/server/services/reports/queries"; import { readCtx } from "@/server/services/reports/read-ctx"; import { ReportStatusBadge } from "../status-badge"; import { StepIndicator } from "../step-indicator"; import { SignFlow } from "./sign-flow"; /** /m/orders/[id]/sign — signature or documented reason, then submit the completion report. */ export async function SignScreen({ workOrderId }: { workOrderId: string }) { const t = await getTranslations("reports"); const format = await getFormatter(); const ctx = await readCtx(); let state: Awaited>; try { state = await getMobileReportState(ctx, workOrderId, "completion"); } catch (err) { if (err instanceof ServiceError && err.code === "not_found") notFound(); throw err; } const { workOrder, report, content, timeZone } = state; const base = `/m/orders/${workOrderId}`; const steps = [t("mobile.stepReview"), t("mobile.stepEdit"), t("mobile.stepSign"), t("mobile.stepSubmit")]; return (
{t("mobile.review")}

{workOrder.number} · {workOrder.title}

{t("sign.title")}

{!report || !content ? (

{t("sign.noReport")}{" "} {t("mobile.createCompletion")}

) : ( <>
{content.reportNumber} · {t("field.version")} {report.version}
)}
); }