fix(dashboard): Prevent order details page from crashing on no region (#10431)

Resolves SUP-356
This commit is contained in:
Kasper Fabricius Kristensen authored and GitHub committed 2024-12-04 16:18:54 +00:00
1 parent c6f955f0b5
commit 3d5ca155e3
2 files changed
+11 -6

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@medusajs/dashboard": patch
---
fix(dashboard): Prevent order details page from crashing on no region
@@ -24,6 +24,7 @@ import {
import { import {
Badge, Badge,
Button, Button,
clx,
Container, Container,
Copy, Copy,
Heading, Heading,
@@ -32,9 +33,9 @@ import {
toast, toast,
Tooltip, Tooltip,
usePrompt, usePrompt,
clx,
} from "@medusajs/ui" } from "@medusajs/ui"
import { AdminReservation } from "@medusajs/types/src/http"
import { AdminPaymentCollection } from "../../../../../../../../core/types/dist/http/payment/admin/entities" import { AdminPaymentCollection } from "../../../../../../../../core/types/dist/http/payment/admin/entities"
import { ActionMenu } from "../../../../../components/common/action-menu" import { ActionMenu } from "../../../../../components/common/action-menu"
import { ButtonMenu } from "../../../../../components/common/button-menu/button-menu" import { ButtonMenu } from "../../../../../components/common/button-menu/button-menu"
@@ -56,7 +57,6 @@ import { getReturnableQuantity } from "../../../../../lib/rma"
import { CopyPaymentLink } from "../copy-payment-link/copy-payment-link" import { CopyPaymentLink } from "../copy-payment-link/copy-payment-link"
import ReturnInfoPopover from "./return-info-popover" import ReturnInfoPopover from "./return-info-popover"
import ShippingInfoPopover from "./shipping-info-popover" import ShippingInfoPopover from "./shipping-info-popover"
import { AdminReservation } from "@medusajs/types/src/http"
type OrderSummarySectionProps = { type OrderSummarySectionProps = {
order: AdminOrder order: AdminOrder
@@ -341,7 +341,7 @@ const Header = ({
shouldDisableReturn || shouldDisableReturn ||
isOrderEditActive || isOrderEditActive ||
(!!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,
}, },
{ {
@@ -356,7 +356,7 @@ const Header = ({
shouldDisableReturn || shouldDisableReturn ||
isOrderEditActive || isOrderEditActive ||
(!!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,
}, },
], ],
@@ -555,7 +555,7 @@ const Cost = ({
const CostBreakdown = ({ const CostBreakdown = ({
order, order,
}: { }: {
order: AdminOrder & { region: AdminRegion } order: AdminOrder & { region?: AdminRegion | null }
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const [isTaxOpen, setIsTaxOpen] = useState(false) const [isTaxOpen, setIsTaxOpen] = useState(false)
@@ -590,7 +590,7 @@ const CostBreakdown = ({
return taxCodeMap return taxCodeMap
}, [order]) }, [order])
const automaticTaxesOn = !!order.region!.automatic_taxes const automaticTaxesOn = !!order.region?.automatic_taxes
const hasTaxLines = !!Object.keys(taxCodes).length const hasTaxLines = !!Object.keys(taxCodes).length
const discountTotal = automaticTaxesOn const discountTotal = automaticTaxesOn