Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/purple-tips-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/dashboard": patch
---

fix(dashboard): Prevent order details page from crashing on no region
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import {
Badge,
Button,
clx,
Container,
Copy,
Heading,
Expand All @@ -32,9 +33,9 @@ import {
toast,
Tooltip,
usePrompt,
clx,
} from "@medusajs/ui"

import { AdminReservation } from "@medusajs/types/src/http"
import { AdminPaymentCollection } from "../../../../../../../../core/types/dist/http/payment/admin/entities"
import { ActionMenu } from "../../../../../components/common/action-menu"
import { ButtonMenu } from "../../../../../components/common/button-menu/button-menu"
Expand All @@ -56,7 +57,6 @@ import { getReturnableQuantity } from "../../../../../lib/rma"
import { CopyPaymentLink } from "../copy-payment-link/copy-payment-link"
import ReturnInfoPopover from "./return-info-popover"
import ShippingInfoPopover from "./shipping-info-popover"
import { AdminReservation } from "@medusajs/types/src/http"

type OrderSummarySectionProps = {
order: AdminOrder
Expand Down Expand Up @@ -341,7 +341,7 @@ const Header = ({
shouldDisableReturn ||
isOrderEditActive ||
(!!orderPreview?.order_change?.return_id &&
!!!orderPreview?.order_change?.exchange_id) ||
!orderPreview?.order_change?.exchange_id) ||
!!orderPreview?.order_change?.claim_id,
},
{
Expand All @@ -356,7 +356,7 @@ const Header = ({
shouldDisableReturn ||
isOrderEditActive ||
(!!orderPreview?.order_change?.return_id &&
!!!orderPreview?.order_change?.claim_id) ||
!orderPreview?.order_change?.claim_id) ||
!!orderPreview?.order_change?.exchange_id,
},
],
Expand Down Expand Up @@ -555,7 +555,7 @@ const Cost = ({
const CostBreakdown = ({
order,
}: {
order: AdminOrder & { region: AdminRegion }
order: AdminOrder & { region?: AdminRegion | null }
}) => {
const { t } = useTranslation()
const [isTaxOpen, setIsTaxOpen] = useState(false)
Expand Down Expand Up @@ -590,7 +590,7 @@ const CostBreakdown = ({
return taxCodeMap
}, [order])

const automaticTaxesOn = !!order.region!.automatic_taxes
const automaticTaxesOn = !!order.region?.automatic_taxes
const hasTaxLines = !!Object.keys(taxCodes).length

const discountTotal = automaticTaxesOn
Expand Down
Loading