fix(dashboard): disable RMAs if there is no shipped items (#8652)
This commit is contained in:
+13
-4
@@ -44,6 +44,7 @@ import {
|
|||||||
getStylizedAmount,
|
getStylizedAmount,
|
||||||
} from "../../../../../lib/money-amount-helpers"
|
} from "../../../../../lib/money-amount-helpers"
|
||||||
import { getTotalCaptured } from "../../../../../lib/payment.ts"
|
import { getTotalCaptured } from "../../../../../lib/payment.ts"
|
||||||
|
import { getReturnableQuantity } from "../../../../../lib/rma.ts"
|
||||||
|
|
||||||
type OrderSummarySectionProps = {
|
type OrderSummarySectionProps = {
|
||||||
order: AdminOrder
|
order: AdminOrder
|
||||||
@@ -147,6 +148,11 @@ const Header = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
// is ture if there is no shipped items ATM
|
||||||
|
const shouldDisableReturn = order.items.every(
|
||||||
|
(i) => !(getReturnableQuantity(i) > 0)
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-between px-6 py-4">
|
<div className="flex items-center justify-between px-6 py-4">
|
||||||
<Heading level="h2">{t("fields.summary")}</Heading>
|
<Heading level="h2">{t("fields.summary")}</Heading>
|
||||||
@@ -169,6 +175,7 @@ const Header = ({
|
|||||||
to: `/orders/${order.id}/returns`,
|
to: `/orders/${order.id}/returns`,
|
||||||
icon: <ArrowUturnLeft />,
|
icon: <ArrowUturnLeft />,
|
||||||
disabled:
|
disabled:
|
||||||
|
shouldDisableReturn ||
|
||||||
!!orderPreview?.order_change?.exchange_id ||
|
!!orderPreview?.order_change?.exchange_id ||
|
||||||
!!orderPreview?.order_change?.claim_id,
|
!!orderPreview?.order_change?.claim_id,
|
||||||
},
|
},
|
||||||
@@ -181,6 +188,7 @@ const Header = ({
|
|||||||
to: `/orders/${order.id}/exchanges`,
|
to: `/orders/${order.id}/exchanges`,
|
||||||
icon: <ArrowPath />,
|
icon: <ArrowPath />,
|
||||||
disabled:
|
disabled:
|
||||||
|
shouldDisableReturn ||
|
||||||
(!!orderPreview?.order_change?.return_id &&
|
(!!orderPreview?.order_change?.return_id &&
|
||||||
!!!orderPreview?.order_change?.exchange_id) ||
|
!!!orderPreview?.order_change?.exchange_id) ||
|
||||||
!!orderPreview?.order_change?.claim_id,
|
!!orderPreview?.order_change?.claim_id,
|
||||||
@@ -194,6 +202,7 @@ const Header = ({
|
|||||||
to: `/orders/${order.id}/claims`,
|
to: `/orders/${order.id}/claims`,
|
||||||
icon: <ExclamationCircle />,
|
icon: <ExclamationCircle />,
|
||||||
disabled:
|
disabled:
|
||||||
|
shouldDisableReturn ||
|
||||||
(!!orderPreview?.order_change?.return_id &&
|
(!!orderPreview?.order_change?.return_id &&
|
||||||
!!!orderPreview?.order_change?.claim_id) ||
|
!!!orderPreview?.order_change?.claim_id) ||
|
||||||
!!orderPreview?.order_change?.exchange_id,
|
!!orderPreview?.order_change?.exchange_id,
|
||||||
@@ -431,7 +440,7 @@ const ReturnBreakdown = ({
|
|||||||
item && (
|
item && (
|
||||||
<div
|
<div
|
||||||
key={orderReturn.id}
|
key={orderReturn.id}
|
||||||
className="txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-subtle border-dotted border-t-2 border-b-2 flex flex-row justify-between gap-y-2 px-6 py-4"
|
className="txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-subtle flex flex-row justify-between gap-y-2 border-b-2 border-t-2 border-dotted px-6 py-4"
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<ArrowDownRightMini className="text-ui-fg-muted" />
|
<ArrowDownRightMini className="text-ui-fg-muted" />
|
||||||
@@ -449,7 +458,7 @@ const ReturnBreakdown = ({
|
|||||||
|
|
||||||
{item?.note && (
|
{item?.note && (
|
||||||
<Tooltip content={item.note}>
|
<Tooltip content={item.note}>
|
||||||
<DocumentText className="text-ui-tag-neutral-icon inline ml-1" />
|
<DocumentText className="text-ui-tag-neutral-icon ml-1 inline" />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -493,7 +502,7 @@ const ClaimBreakdown = ({
|
|||||||
!!items.length && (
|
!!items.length && (
|
||||||
<div
|
<div
|
||||||
key={claim.id}
|
key={claim.id}
|
||||||
className="txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-subtle border-dotted border-t-2 border-b-2 flex flex-row justify-between gap-y-2 px-6 py-4"
|
className="txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-subtle flex flex-row justify-between gap-y-2 border-b-2 border-t-2 border-dotted px-6 py-4"
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<ArrowDownRightMini className="text-ui-fg-muted" />
|
<ArrowDownRightMini className="text-ui-fg-muted" />
|
||||||
@@ -532,7 +541,7 @@ const ExchangeBreakdown = ({
|
|||||||
!!items.length && (
|
!!items.length && (
|
||||||
<div
|
<div
|
||||||
key={exchange.id}
|
key={exchange.id}
|
||||||
className="txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-subtle border-dotted border-t-2 border-b-2 flex flex-row justify-between gap-y-2 px-6 py-4"
|
className="txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-subtle flex flex-row justify-between gap-y-2 border-b-2 border-t-2 border-dotted px-6 py-4"
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<ArrowDownRightMini className="text-ui-fg-muted" />
|
<ArrowDownRightMini className="text-ui-fg-muted" />
|
||||||
|
|||||||
Reference in New Issue
Block a user