diff --git a/src/actions/stops/get-stop-details.ts b/src/actions/stops/get-stop-details.ts index c31bc78..69f3494 100644 --- a/src/actions/stops/get-stop-details.ts +++ b/src/actions/stops/get-stop-details.ts @@ -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 allProducts: allProducts ?? [], assignedProducts: (productStops ?? []) as AssignedProduct[], brands: brands ?? [], + callerUid: adminUser.user_id, }; } diff --git a/src/components/admin/StopDetailModal.tsx b/src/components/admin/StopDetailModal.tsx index 2cd16e8..a44a8fa 100644 --- a/src/components/admin/StopDetailModal.tsx +++ b/src/components/admin/StopDetailModal.tsx @@ -31,6 +31,7 @@ export default function StopDetailModal({ stopId, onDuplicate, onClose }: Props) const [allProducts, setAllProducts] = useState<{ id: string; name: string; type: string; price: number }[]>([]); const [assignedProducts, setAssignedProducts] = useState([]); const [brands, setBrands] = useState<{ id: string; name: string; slug: string }[]>([]); + const [callerUid, setCallerUid] = useState(""); const [tab, setTab] = useState("details"); useEffect(() => { @@ -49,6 +50,7 @@ export default function StopDetailModal({ stopId, onDuplicate, onClose }: Props) setAllProducts(res.allProducts); setAssignedProducts(res.assignedProducts); setBrands(res.brands); + setCallerUid(res.callerUid); setLoading(false); }) .catch((err) => { @@ -68,6 +70,7 @@ export default function StopDetailModal({ stopId, onDuplicate, onClose }: Props) setAllProducts(res.allProducts); setAssignedProducts(res.assignedProducts); setBrands(res.brands); + setCallerUid(res.callerUid); }); } @@ -145,7 +148,7 @@ export default function StopDetailModal({ stopId, onDuplicate, onClose }: Props) stopId={stop.id} allProducts={allProducts} assignedProducts={assignedProducts} - callerUid={stop.id} + callerUid={callerUid} />