From 990dd0dc23f17dff5fc0af93dd7f63090d35b83a Mon Sep 17 00:00:00 2001 From: abhishek Date: Tue, 6 Oct 2026 12:20:13 +0530 Subject: [PATCH] toggle update --- src/features/store-admin/ProductDrawer.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/features/store-admin/ProductDrawer.tsx b/src/features/store-admin/ProductDrawer.tsx index 10b0aec..50034fc 100644 --- a/src/features/store-admin/ProductDrawer.tsx +++ b/src/features/store-admin/ProductDrawer.tsx @@ -158,8 +158,22 @@ export function ProductDrawer({ const [scoreError, setScoreError] = useState(null); const showScore = useMutation({ + /* + The PRODUCT's tenant, not the branch scope's. + + `useBranchScope` reads `user?.tenantid ?? 0`, so a session whose record + carries no tenant hands this a 0 — and the service refuses that outright, + which until recently failed in silence. The product row already names its + own tenant, the toggle's own guard requires it to be there before the + switch renders at all, and a per-product write is scoped by the product. + One source, and it is the one that cannot be absent. + */ mutationFn: (show: boolean) => - productsApi.setShowHealthScore(tenantid as number, product.productid, show), + productsApi.setShowHealthScore( + product.tenantid ?? (tenantid as number), + product.productid, + show, + ), onMutate: (show: boolean) => { setScoreError(null); setScoreShown(show);