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 <noreply@anthropic.com> Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
parent
8b6b10d64b
commit
064f13a7ca
1 changed files with 8 additions and 4 deletions
|
|
@ -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}"`,
|
||||
|
|
|
|||
Loading…
Reference in a new issue