From b7f9a6aaeb1b1524bda2a47a8b9c75b7997b083d Mon Sep 17 00:00:00 2001 From: abhishek Date: Mon, 5 Oct 2026 19:20:08 +0530 Subject: [PATCH] my stock update page ui --- src/features/store-admin/ProductDrawer.tsx | 9 ++- .../store-admin/pages/InventoryPage.tsx | 79 +++++++------------ 2 files changed, 37 insertions(+), 51 deletions(-) diff --git a/src/features/store-admin/ProductDrawer.tsx b/src/features/store-admin/ProductDrawer.tsx index 62c89bf..0047d30 100644 --- a/src/features/store-admin/ProductDrawer.tsx +++ b/src/features/store-admin/ProductDrawer.tsx @@ -260,10 +260,17 @@ export function ProductDrawer({ {/* ── Health score ────────────────────────────────────────────────── Under Sizes and above the shop detail: it is what a SHOPPER reads, and it belongs with the other shopper-facing facts. */} + {/* The toggle is behind `canManage` for the same reason hiding a product + is: it writes `products.showhealthscore`, which is per TENANT and not + per outlet, so a branch turning a rating off would turn it off at + every shop the business runs. Absent rather than disabled — a greyed + switch invites "why", and the answer is that it is not a decision one + outlet makes. The panel itself still renders: a branch user sees what + a customer sees, they just cannot change it. */} showScore.mutate(show) } : {})} /> diff --git a/src/features/store-admin/pages/InventoryPage.tsx b/src/features/store-admin/pages/InventoryPage.tsx index b62c4d5..c3ab2a3 100644 --- a/src/features/store-admin/pages/InventoryPage.tsx +++ b/src/features/store-admin/pages/InventoryPage.tsx @@ -227,14 +227,14 @@ function RequestsPanel({ }; const decide = useMutation({ - mutationFn: ({ requestid, action }: { requestid: number; action: 'approve' | 'reject' | 'arrive' }) => - action === 'approve' - ? stockApi.approve(requestid) - : action === 'arrive' - ? stockApi.confirmArrival(requestid) - : stockApi.reject(requestid), + /* No 'arrive' here. Confirming arrival writes stock onto a branch's + shelf and belongs to the branch — see the row actions below. Narrowing + the type rather than leaving the branch unreachable, so a future caller + cannot quietly reintroduce it from this screen. */ + mutationFn: ({ requestid, action }: { requestid: number; action: 'approve' | 'reject' }) => + action === 'approve' ? stockApi.approve(requestid) : stockApi.reject(requestid), onSuccess: (_data, { action }) => { - const verb = action === 'approve' ? 'approved' : action === 'arrive' ? 'confirmed as arrived' : 'rejected'; + const verb = action === 'approve' ? 'approved' : 'rejected'; setOutcome(`Request ${verb}.`); }, onError: () => { @@ -292,26 +292,14 @@ function RequestsPanel({ [requests, selection], ); - const selectedInTransit = useMemo( - () => - requests - .filter((r) => selection.has(r.requestid) && r.status === 'Approved') - .map((r) => r.requestid), - [requests, selection], - ); const decideBatch = useMutation({ - mutationFn: ({ ids, action }: { ids: number[]; action: 'approve' | 'reject' | 'arrive' }) => - action === 'approve' - ? stockApi.approveMany(ids) - : action === 'arrive' - ? stockApi.confirmArrivalMany(ids) - : stockApi.rejectMany(ids), + mutationFn: ({ ids, action }: { ids: number[]; action: 'approve' | 'reject' }) => + action === 'approve' ? stockApi.approveMany(ids) : stockApi.rejectMany(ids), onSuccess: (result, { ids, action }) => { const done = result?.updated?.length ?? ids.length; const failed = result?.failed?.length ?? 0; - const verb = - action === 'approve' ? 'approved' : action === 'arrive' ? 'added to shelf' : 'rejected'; + const verb = action === 'approve' ? 'approved' : 'rejected'; setOutcome( failed === 0 ? `${count(done)} request${done === 1 ? '' : 's'} ${verb}.` @@ -490,21 +478,11 @@ function RequestsPanel({ /> ) : null} - {selectedInTransit.length > 0 ? ( -