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) <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-24 08:54:46 +00:00
parent 909657fff7
commit 00ed03098a
3 changed files with 21 additions and 12 deletions

View file

@ -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;
}

View file

@ -39,7 +39,8 @@ vi.mock("next/link", () => ({
}) => <a href={href}>{children}</a>,
}));
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";

View file

@ -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: {
</div>
);
}
/**
* 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;
}