fix(admin/stops): pass admin user_id, not stop.id, as callerUid

StopDetailModal was hardcoding callerUid={stop.id} when rendering
StopProductAssignment, so assign_product_to_stop received the stop's
own UUID as p_caller_uid. The RPC's admin_users.user_id lookup
returned no row, so every assign attempt failed with
'Not recognized as admin'.

The admin's user_id is already known inside the getStopDetails
server action (it gates on getAdminUser()), so surface it on the
response and read it in the modal. The sibling /admin/stops/[id]
page already uses the same source (adminUser.user_id) — this brings
the modal in line with it.
This commit is contained in:
2026-06-04 17:37:17 +00:00
parent 6c6b5d3053
commit 66c6f45efc
2 changed files with 7 additions and 1 deletions
+3
View File
@@ -32,6 +32,8 @@ export type StopDetailsResult =
allProducts: { id: string; name: string; type: string; price: number }[];
assignedProducts: AssignedProduct[];
brands: { id: string; name: string; slug: string }[];
/** admin_users.user_id of the caller, forwarded to RPCs that authorise via user_id lookup */
callerUid: string;
}
| { success: false; error: string };
@@ -115,5 +117,6 @@ export async function getStopDetails(stopId: string): Promise<StopDetailsResult>
allProducts: allProducts ?? [],
assignedProducts: (productStops ?? []) as AssignedProduct[],
brands: brands ?? [],
callerUid: adminUser.user_id,
};
}