toggle update
This commit is contained in:
@@ -158,8 +158,22 @@ export function ProductDrawer({
|
|||||||
const [scoreError, setScoreError] = useState<string | null>(null);
|
const [scoreError, setScoreError] = useState<string | null>(null);
|
||||||
|
|
||||||
const showScore = useMutation({
|
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) =>
|
mutationFn: (show: boolean) =>
|
||||||
productsApi.setShowHealthScore(tenantid as number, product.productid, show),
|
productsApi.setShowHealthScore(
|
||||||
|
product.tenantid ?? (tenantid as number),
|
||||||
|
product.productid,
|
||||||
|
show,
|
||||||
|
),
|
||||||
onMutate: (show: boolean) => {
|
onMutate: (show: boolean) => {
|
||||||
setScoreError(null);
|
setScoreError(null);
|
||||||
setScoreShown(show);
|
setScoreShown(show);
|
||||||
|
|||||||
Reference in New Issue
Block a user