From 574b93022c0b32ff7862aee8ebd3b34024ac0e2e Mon Sep 17 00:00:00 2001 From: riyadhafraa <49757212-riyadhafraa@users.noreply.replit.com> Date: Mon, 27 Apr 2026 12:14:42 +0000 Subject: [PATCH] Treat 404 in incoming-order actions as "no longer available" Task #87: Confirm-receipt should also handle the case where the order was deleted. When an admin deletes an order while a receiver is viewing it, the API returns 404 Order not found for confirm-receipt and the status PATCH. Previously the UI showed the generic "Could not complete the action" toast and left the stale card in place. Updated all three onError branches in `artifacts/tx-os/src/pages/orders-incoming.tsx` so 404 responses are handled the same way as the existing `order_unavailable` 409: - handleConfirmReceipt: 404 now shows the localized "incomingOrders.orderUnavailable" toast instead of "actionFailed". invalidate() was already called for every error in this branch, so the stale card is removed. - handleSetStatus (preparing/completed): 404 now shows the "orderUnavailable" toast and calls invalidate() to drop the card. - handleCancel: same treatment for 404 on the cancel PATCH. The 409 already-claimed branch is preserved unchanged. No new translation keys were needed; `incomingOrders.orderUnavailable` already exists in both `src/locales/en.json` and `src/locales/ar.json`. Pre-existing TypeScript errors in `src/pages/admin.tsx` are unrelated to this change. Replit-Task-Id: a923d4f2-0a45-4816-aee9-0822c5677b88 --- artifacts/tx-os/src/pages/orders-incoming.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/artifacts/tx-os/src/pages/orders-incoming.tsx b/artifacts/tx-os/src/pages/orders-incoming.tsx index 41142d60..ac17f1d0 100644 --- a/artifacts/tx-os/src/pages/orders-incoming.tsx +++ b/artifacts/tx-os/src/pages/orders-incoming.tsx @@ -122,7 +122,10 @@ function IncomingOrderCard({ const apiErr = err as { status?: number; data?: { error?: string } } | null; const status = apiErr?.status; const code = apiErr?.data?.error; - if (status === 409 && code === "order_unavailable") { + if ( + (status === 409 && code === "order_unavailable") || + status === 404 + ) { toast({ title: t("incomingOrders.orderUnavailable"), variant: "destructive", @@ -158,7 +161,10 @@ function IncomingOrderCard({ }, onError: (err: unknown) => { const apiErr = err as { status?: number; data?: { error?: string } } | null; - if (apiErr?.status === 409 && apiErr?.data?.error === "order_unavailable") { + if ( + (apiErr?.status === 409 && apiErr?.data?.error === "order_unavailable") || + apiErr?.status === 404 + ) { toast({ title: t("incomingOrders.orderUnavailable"), variant: "destructive", @@ -220,7 +226,10 @@ function IncomingOrderCard({ }, onError: (err: unknown) => { const apiErr = err as { status?: number; data?: { error?: string } } | null; - if (apiErr?.status === 409 && apiErr?.data?.error === "order_unavailable") { + if ( + (apiErr?.status === 409 && apiErr?.data?.error === "order_unavailable") || + apiErr?.status === 404 + ) { toast({ title: t("incomingOrders.orderUnavailable"), variant: "destructive",