From 00ed03098a40d38573fbc1e2c30690fbcee6a944 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Fri, 24 Jul 2026 08:54:46 +0000 Subject: [PATCH] fix(ara-projects): move parseWorkOrderId out of page.tsx (#422) Next.js rejects any non-default export from a page module beyond its allowed fields, so the `parseWorkOrderId` helper failed the production type check on Vercel. Move it to a colocated `ids.ts`; page.tsx now exports only `metadata` and the default page. Behaviour and tests are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../work-orders/[workOrderId]/ids.ts | 18 ++++++++++++++++++ .../work-orders/[workOrderId]/page.test.tsx | 3 ++- .../work-orders/[workOrderId]/page.tsx | 12 +----------- 3 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 src/app/projects/[projectId]/work-orders/[workOrderId]/ids.ts diff --git a/src/app/projects/[projectId]/work-orders/[workOrderId]/ids.ts b/src/app/projects/[projectId]/work-orders/[workOrderId]/ids.ts new file mode 100644 index 00000000..470722fd --- /dev/null +++ b/src/app/projects/[projectId]/work-orders/[workOrderId]/ids.ts @@ -0,0 +1,18 @@ +/** + * Path-segment parsing for the work-order detail route (issue #422). + * + * Kept out of `page.tsx` because Next.js rejects any non-default export from a + * page module beyond its handful of allowed fields — a helper exported there + * fails the build. Mirrors `parseProjectId` in `../../../guards`. + */ + +/** + * Parse a `[workOrderId]` path segment into the bigint PK it addresses, or null + * for anything that is not a bare positive integer — so a junk segment becomes + * a 404 rather than a Drizzle error. + */ +export function parseWorkOrderId(workOrderId: string): bigint | null { + if (!/^\d+$/.test(workOrderId)) return null; + const parsed = BigInt(workOrderId); + return parsed > 0n ? parsed : null; +} diff --git a/src/app/projects/[projectId]/work-orders/[workOrderId]/page.test.tsx b/src/app/projects/[projectId]/work-orders/[workOrderId]/page.test.tsx index 5111b09a..54c8d7d9 100644 --- a/src/app/projects/[projectId]/work-orders/[workOrderId]/page.test.tsx +++ b/src/app/projects/[projectId]/work-orders/[workOrderId]/page.test.tsx @@ -39,7 +39,8 @@ vi.mock("next/link", () => ({ }) => {children}, })); -import WorkOrderDetailPage, { parseWorkOrderId } from "./page"; +import WorkOrderDetailPage from "./page"; +import { parseWorkOrderId } from "./ids"; const CLIENT_ORG = "11111111-1111-1111-1111-111111111111"; const CONTRACTOR_ORG = "22222222-2222-2222-2222-222222222222"; diff --git a/src/app/projects/[projectId]/work-orders/[workOrderId]/page.tsx b/src/app/projects/[projectId]/work-orders/[workOrderId]/page.tsx index 6a6641e8..d3dbbecf 100644 --- a/src/app/projects/[projectId]/work-orders/[workOrderId]/page.tsx +++ b/src/app/projects/[projectId]/work-orders/[workOrderId]/page.tsx @@ -15,6 +15,7 @@ import { WorkOrderHeader, } from "./components/WorkOrderDetailPanels"; import { EvidenceUploadSlot, StageUpdateSlot } from "./components/ActionSlots"; +import { parseWorkOrderId } from "./ids"; export const metadata = { title: "Work order | Ara", @@ -93,14 +94,3 @@ export default async function WorkOrderDetailPage(props: { ); } - -/** - * Parse a `[workOrderId]` path segment into the bigint PK it addresses, or null - * for anything that is not a bare positive integer — so a junk segment becomes - * a 404 rather than a Drizzle error. Mirrors `parseProjectId` in the guards. - */ -export function parseWorkOrderId(workOrderId: string): bigint | null { - if (!/^\d+$/.test(workOrderId)) return null; - const parsed = BigInt(workOrderId); - return parsed > 0n ? parsed : null; -}