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
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user