diff --git a/packages/admin-next/dashboard/src/i18n/translations/en.json b/packages/admin-next/dashboard/src/i18n/translations/en.json index dd3c06df12..968a8c426f 100644 --- a/packages/admin-next/dashboard/src/i18n/translations/en.json +++ b/packages/admin-next/dashboard/src/i18n/translations/en.json @@ -969,7 +969,6 @@ "create": "Create Claim", "confirm": "Confirm Claim", "confirmText": "You are about to confirm a Claim. This action cannot be undone.", - "cancel": "Cancel Claim", "manage": "Manage Claim", "outbound": "Outbound", "outboundItemAdded": "{{itemsCount}}x added through claim", @@ -983,6 +982,10 @@ "successToast": "Claim was successfully canceled." } }, + "cancel": { + "title": "Cancel Claim", + "description": "Are you sure you want to cancel the claim?" + }, "tooltips": { "onlyReturnShippingOptions": "This list will consist of only return shipping options." }, @@ -1000,7 +1003,6 @@ "manage": "Manage Exchange", "confirm": "Confirm Exchange", "confirmText": "You are about to confirm an Exchange. This action cannot be undone.", - "cancel": "Cancel Exchange", "outbound": "Outbound", "outboundItemAdded": "{{itemsCount}}x added through exchange", "outboundTotal": "Outbound total", @@ -1013,6 +1015,10 @@ "successToast": "Exchange was successfully canceled." } }, + "cancel": { + "title": "Cancel Exchange", + "description": "Are you sure you want to cancel the exchange?" + }, "tooltips": { "onlyReturnShippingOptions": "This list will consist of only return shipping options." }, @@ -1160,16 +1166,17 @@ }, "claim": { "created": "Claim #{{claimId}} requested", + "canceled": "Claim #{{claimId}} canceled", "itemsInbound": "{{count}} item to return", "itemsOutbound": "{{count}} item to send" }, "exchange": { "created": "Exchange #{{exchangeId}} requested", + "canceled": "Exchange #{{exchangeId}} canceled", "itemsInbound": "{{count}} item to return", "itemsOutbound": "{{count}} item to send" }, "edit": { - "requested": "Order edit #{{editId}} requested", "requested": "Order edit #{{editId}} requested", "confirmed": "Order edit #{{editId}} confirmed" } diff --git a/packages/admin-next/dashboard/src/routes/orders/order-create-claim/components/claim-create-form/claim-create-form.tsx b/packages/admin-next/dashboard/src/routes/orders/order-create-claim/components/claim-create-form/claim-create-form.tsx index 7ecaed3416..9e39ca656d 100644 --- a/packages/admin-next/dashboard/src/routes/orders/order-create-claim/components/claim-create-form/claim-create-form.tsx +++ b/packages/admin-next/dashboard/src/routes/orders/order-create-claim/components/claim-create-form/claim-create-form.tsx @@ -1003,7 +1003,7 @@ export const ClaimCreateForm = ({ variant="secondary" size="small" > - {t("orders.claims.cancel")} + {t("orders.claims.cancel.title")} diff --git a/packages/admin-next/dashboard/src/routes/orders/order-detail/components/active-order-claim-section/active-order-claim-section.tsx b/packages/admin-next/dashboard/src/routes/orders/order-detail/components/active-order-claim-section/active-order-claim-section.tsx index d48a519afc..ba2f35da1d 100644 --- a/packages/admin-next/dashboard/src/routes/orders/order-detail/components/active-order-claim-section/active-order-claim-section.tsx +++ b/packages/admin-next/dashboard/src/routes/orders/order-detail/components/active-order-claim-section/active-order-claim-section.tsx @@ -65,7 +65,7 @@ export const ActiveOrderClaimSection = ({
+ )}
) } @@ -687,8 +731,31 @@ const ExchangeBody = ({ exchange: AdminExchange exchangeReturn?: AdminReturn }) => { + const prompt = usePrompt() const { t } = useTranslation() + const isCanceled = !!exchange.canceled_at + + const { mutateAsync: cancelExchange } = useCancelExchange( + exchange.id, + exchange.order_id + ) + + const onCancel = async () => { + const res = await prompt({ + title: t("orders.exchanges.cancel.title"), + description: t("orders.exchanges.cancel.description"), + confirmText: t("actions.confirm"), + cancelText: t("actions.cancel"), + }) + + if (!res) { + return + } + + await cancelExchange() + } + const outboundItems = (exchange.additional_items || []).reduce( (acc, item) => (acc + item.quantity) as number, 0 @@ -716,6 +783,17 @@ const ExchangeBody = ({ })} )} + + {!isCanceled && ( + + )} ) }