From 064f13a7cab4269e3dec1a0e42386207582b02ab Mon Sep 17 00:00:00 2001 From: SJCoetz Date: Wed, 29 Jul 2026 16:19:40 +0200 Subject: [PATCH] fix(orders): use client PB for customer list in modal mount getAdminPocketBase reads PB_ADMIN_EMAIL/PB_ADMIN_PASSWORD which are server-only env vars. The modal mount is a client component, so the admin client would fail to authenticate at runtime. The users PB session already has read access; switch to getPocketBase. Co-Authored-By: Claude Opus 4.8 Co-authored-by: Orca --- src/app/(app)/orders/page.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/(app)/orders/page.tsx b/src/app/(app)/orders/page.tsx index 65c9aec..c93cd8a 100644 --- a/src/app/(app)/orders/page.tsx +++ b/src/app/(app)/orders/page.tsx @@ -104,12 +104,16 @@ function OrdersReviewModalMount({ (async () => { try { const { getOrder, getOrderItems } = await import("@/lib/pb-helpers"); - const { getAdminPocketBase } = await import("@/lib/server/pocketbase-admin"); - const adminPb = await getAdminPocketBase(); + // Use the BROWSER PB instance (not the admin one) — admin PB + // requires server-only env vars and would break in the browser + // bundle. The user's session PB already has read access to + // customers + quote_attachments, so we don't need privileges. + const { getPocketBase } = await import("@/lib/pocketbase"); + const pb = getPocketBase(); const [order, items, customersResult] = await Promise.all([ getOrder(orderId), getOrderItems(orderId), - adminPb.collection("customers").getFullList({ + pb.collection("customers").getFullList({ sort: "-created", expand: "company", }), @@ -125,7 +129,7 @@ function OrdersReviewModalMount({ | undefined; const attachments = quote - ? await adminPb + ? await pb .collection("quote_attachments") .getFullList({ filter: `quote = "${quote.id}"`,