diff --git a/.changeset/spicy-carrots-itch.md b/.changeset/spicy-carrots-itch.md
new file mode 100644
index 0000000000000..c7b3e9375b388
--- /dev/null
+++ b/.changeset/spicy-carrots-itch.md
@@ -0,0 +1,5 @@
+---
+"@medusajs/dashboard": patch
+---
+
+fix(dashboard): Cleanup unsafe accesses to possibly undefined values in order timeline
diff --git a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-activity-section/order-timeline.tsx b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-activity-section/order-timeline.tsx
index 6563fb6b9b1f0..ed64a962930be 100644
--- a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-activity-section/order-timeline.tsx
+++ b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-activity-section/order-timeline.tsx
@@ -1,10 +1,8 @@
-import { Button, IconButton, Text, Tooltip, clx, usePrompt } from "@medusajs/ui"
+import { Button, Text, Tooltip, clx, usePrompt } from "@medusajs/ui"
import * as Collapsible from "@radix-ui/react-collapsible"
import { PropsWithChildren, ReactNode, useMemo, useState } from "react"
-import { Link } from "react-router-dom"
-import { XMarkMini } from "@medusajs/icons"
import {
AdminClaim,
AdminExchange,
@@ -16,6 +14,7 @@ import {
import { useTranslation } from "react-i18next"
import { AdminOrderLineItem } from "@medusajs/types"
+import { By } from "../../../../../components/common/user-link"
import {
useCancelOrderTransfer,
useCustomer,
@@ -29,12 +28,11 @@ import {
} from "../../../../../hooks/api/exchanges"
import { useCancelReturn, useReturns } from "../../../../../hooks/api/returns"
import { useDate } from "../../../../../hooks/use-date"
+import { getFormattedAddress } from "../../../../../lib/addresses"
import { getStylizedAmount } from "../../../../../lib/money-amount-helpers"
import { getPaymentsFromOrder } from "../order-payment-section"
import ActivityItems from "./activity-items"
-import { By, UserLink } from "../../../../../components/common/user-link"
import ChangeDetailsTooltip from "./change-details-tooltip"
-import { getFormattedAddress } from "../../../../../lib/addresses"
type OrderTimelineProps = {
order: AdminOrder
@@ -394,12 +392,12 @@ const useActivityItems = (order: AdminOrder): Activity[] => {
edit.status === "requested"
? edit.requested_at
: edit.status === "confirmed"
- ? edit.confirmed_at
- : edit.status === "declined"
- ? edit.declined_at
- : edit.status === "canceled"
- ? edit.canceled_at
- : edit.created_at,
+ ? edit.confirmed_at
+ : edit.status === "declined"
+ ? edit.declined_at
+ : edit.status === "canceled"
+ ? edit.canceled_at
+ : edit.created_at,
children: isConfirmed ? : null,
})
}
@@ -455,7 +453,7 @@ const useActivityItems = (order: AdminOrder): Activity[] => {
),
timestamp: update.created_at,
children: (
-
+
{t("fields.by")}
),
@@ -477,7 +475,7 @@ const useActivityItems = (order: AdminOrder): Activity[] => {
),
timestamp: update.created_at,
children: (
-
+
{t("fields.by")}
),
@@ -495,7 +493,7 @@ const useActivityItems = (order: AdminOrder): Activity[] => {
),
timestamp: update.created_at,
children: (
-
+
{t("fields.by")}
),
@@ -674,64 +672,67 @@ const OrderActivityCollapsible = ({
)
}
-const NoteBody = ({ note }: { note: Note }) => {
- const { t } = useTranslation()
- const prompt = usePrompt()
-
- const { first_name, last_name, email } = note.author || {}
- const name = [first_name, last_name].filter(Boolean).join(" ")
-
- const byLine = t("orders.activity.events.note.byLine", {
- author: name || email,
- })
-
- const { mutateAsync } = {} // useAdminDeleteNote(note.id)
-
- const handleDelete = async () => {
- const res = await prompt({
- title: t("general.areYouSure"),
- description: "This action cannot be undone",
- confirmText: t("actions.delete"),
- cancelText: t("actions.cancel"),
- })
-
- if (!res) {
- return
- }
-
- await mutateAsync()
- }
-
- return (
-
-
-
-
- {note.value}
-
-
-
-
- {t("orders.activity.comment.deleteButtonText")}
-
-
-
-
-
-
{byLine}
-
-
- )
-}
+/**
+ * TODO: Add once notes are supported.
+ */
+// const NoteBody = ({ note }: { note: Note }) => {
+// const { t } = useTranslation()
+// const prompt = usePrompt()
+
+// const { first_name, last_name, email } = note.author || {}
+// const name = [first_name, last_name].filter(Boolean).join(" ")
+
+// const byLine = t("orders.activity.events.note.byLine", {
+// author: name || email,
+// })
+
+// const { mutateAsync } = {} // useAdminDeleteNote(note.id)
+
+// const handleDelete = async () => {
+// const res = await prompt({
+// title: t("general.areYouSure"),
+// description: "This action cannot be undone",
+// confirmText: t("actions.delete"),
+// cancelText: t("actions.cancel"),
+// })
+
+// if (!res) {
+// return
+// }
+
+// await mutateAsync()
+// }
+
+// return (
+//
+//
+//
+//
+// {note.value}
+//
+//
+//
+//
+// {t("orders.activity.comment.deleteButtonText")}
+//
+//
+//
+//
+//
+//
{byLine}
+//
+//
+// )
+// }
const FulfillmentCreatedBody = ({
fulfillment,
@@ -1085,11 +1086,15 @@ function getMissingLineItemIds(order: AdminOrder, changes: AdminOrderChange[]) {
changes.forEach((change) => {
change.actions.forEach((action) => {
+ if (!action.details?.reference_id) {
+ return
+ }
+
if (
- (action.details!.reference_id as string).startsWith("ordli_") &&
- !existingItemsMap.has(action.details!.reference_id as string)
+ (action.details.reference_id as string).startsWith("ordli_") &&
+ !existingItemsMap.has(action.details.reference_id as string)
) {
- retIds.add(action.details!.reference_id as string)
+ retIds.add(action.details.reference_id as string)
}
})
})
diff --git a/packages/admin/dashboard/src/routes/shipping-profiles/shipping-profile-create/shipping-profile-create.tsx b/packages/admin/dashboard/src/routes/shipping-profiles/shipping-profile-create/shipping-profile-create.tsx
index 775c5ea240ce6..62b27047ad05b 100644
--- a/packages/admin/dashboard/src/routes/shipping-profiles/shipping-profile-create/shipping-profile-create.tsx
+++ b/packages/admin/dashboard/src/routes/shipping-profiles/shipping-profile-create/shipping-profile-create.tsx
@@ -1,4 +1,3 @@
-
import { RouteFocusModal } from "../../../components/modals"
import { CreateShippingProfileForm } from "./components/create-shipping-profile-form"