From b89a4a7fa3a6ce441f052d491f740cff8474c529 Mon Sep 17 00:00:00 2001 From: SJCoetz Date: Mon, 3 Aug 2026 15:07:46 +0200 Subject: [PATCH] fix(stock-orders): preserve header nav + sanitize error message - Header (title, description, Reorder, + New stock order) now renders unconditionally, so operators can navigate away even when the list query throws. - Full error is logged server-side via console.error; the user sees a generic 'Failed to load stock orders. Please try again.' message that doesn't leak PB URLs, admin env var names, or filter syntax. Co-authored-by: Orca --- src/app/(app)/stock-orders/page.tsx | 43 ++++++++++++++++------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/src/app/(app)/stock-orders/page.tsx b/src/app/(app)/stock-orders/page.tsx index 317c182..95eec73 100644 --- a/src/app/(app)/stock-orders/page.tsx +++ b/src/app/(app)/stock-orders/page.tsx @@ -55,22 +55,18 @@ export default async function StockOrdersPage({ const status = parseStatus(params.status); const page = parsePage(params.page); - let result: Awaited>; + let result: Awaited> | null = null; + let loadError: string | null = null; try { const pb = await getAdminPocketBase(); result = await listStockPurchases(pb, { status, page, perPage: 50 }); } catch (err) { - // Surface the failure inline rather than redirect to a global - // error boundary — operators need the URL context to retry. - return ( -
-

Stock Orders

-

- Failed to load stock orders:{" "} - {err instanceof Error ? err.message : "unknown error"} -

-
- ); + // Log full error server-side so operators have the diagnostic + // trail; show only a generic message to the user — internal + // detail (PB URLs, env-var names, filter syntax) is not safe + // to surface in the operator UI. + console.error("stock-orders list failed:", err); + loadError = "Failed to load stock orders. Please try again."; } return ( @@ -90,18 +86,27 @@ export default async function StockOrdersPage({ > Reorder from low stock - + + New stock order - + {loadError ? ( +
+ {loadError} +
+ ) : ( + + )} ); } \ No newline at end of file