diff --git a/packages/admin-next/dashboard/src/i18n/translations/en.json b/packages/admin-next/dashboard/src/i18n/translations/en.json index d734d29c78..a91edb488e 100644 --- a/packages/admin-next/dashboard/src/i18n/translations/en.json +++ b/packages/admin-next/dashboard/src/i18n/translations/en.json @@ -767,13 +767,11 @@ "canceled": "Payment canceled" }, "fulfillment": { - "created": "Fulfillment created", + "created": "Items fulfilled", "canceled": "Fulfillment canceled", - "shipped": "Fulfillment shipped", - "itemsFulfilledFrom_one": "{{count}} item fulfilled from {{location}}", - "itemsFulfilledFrom_other": "{{count}} items fulfilled from {{location}}", - "itemsFulfilled_one": "{{count}} item fulfilled", - "itemsFulfilled_other": "{{count}} items fulfilled" + "shipped": "Items shipped", + "items_one": "{{count}} item", + "items_other": "{{count}} items" }, "return": { "created": "Return created" @@ -1881,6 +1879,7 @@ "orders": "Orders", "account": "Account", "total": "Total", + "paidTotal": "Paid total", "totalExclTax": "Total excl. tax", "subtotal": "Subtotal", "shipping": "Shipping", diff --git a/packages/admin-next/dashboard/src/routes/orders/order-detail/components/order-activity-section/order-timeline.tsx b/packages/admin-next/dashboard/src/routes/orders/order-detail/components/order-activity-section/order-timeline.tsx index 456a9555c6..1cbdc46029 100644 --- a/packages/admin-next/dashboard/src/routes/orders/order-detail/components/order-activity-section/order-timeline.tsx +++ b/packages/admin-next/dashboard/src/routes/orders/order-detail/components/order-activity-section/order-timeline.tsx @@ -1,4 +1,3 @@ -import { Fulfillment, Note, Order } from "@medusajs/medusa" import { IconButton, Text, Tooltip, clx, usePrompt } from "@medusajs/ui" import * as Collapsible from "@radix-ui/react-collapsible" @@ -6,11 +5,11 @@ import { PropsWithChildren, ReactNode, useMemo, useState } from "react" import { Link } from "react-router-dom" import { XMarkMini } from "@medusajs/icons" -import { AdminOrder } from "@medusajs/types" +import { AdminFulfillment, AdminOrder } from "@medusajs/types" import { useTranslation } from "react-i18next" -import { Skeleton } from "../../../../../components/common/skeleton" + import { useDate } from "../../../../../hooks/use-date" -import { useStockLocation } from "../../../../../hooks/api/stock-locations" +import { getStylizedAmount } from "../../../../../lib/money-amount-helpers" type OrderTimelineProps = { order: AdminOrder @@ -78,7 +77,7 @@ type Activity = { children?: ReactNode } -const useActivityItems = (order: Order) => { +const useActivityItems = (order: AdminOrder) => { const { t } = useTranslation() const notes = [] @@ -141,20 +140,34 @@ const useActivityItems = (order: Order) => { // } // } - // for (const fulfillment of order.fulfillments) { - // items.push({ - // title: t("orders.activity.events.fulfillment.created"), - // timestamp: fulfillment.created_at, - // children: , - // }) - // - // if (fulfillment.shipped_at) { - // items.push({ - // title: t("orders.activity.events.fulfillment.shipped"), - // timestamp: fulfillment.shipped_at, - // }) - // } - // } + for (const fulfillment of order.fulfillments) { + items.push({ + title: t("orders.activity.events.fulfillment.created"), + timestamp: fulfillment.created_at, + children: , + }) + + if (fulfillment.shipped_at) { + items.push({ + title: t("orders.activity.events.fulfillment.shipped"), + timestamp: fulfillment.shipped_at, + children: ( + + ), + }) + } + + if (fulfillment.canceled_at) { + items.push({ + title: t("orders.activity.events.fulfillment.canceled"), + timestamp: fulfillment.canceled_at, + }) + } + } + + /** + * TODO: revisit when API is fixed to fetch returns of an order + */ // for (const ret of order.returns) { // items.push({ @@ -187,9 +200,7 @@ const useActivityItems = (order: Order) => { timestamp: order.created_at, children: ( - {t("orders.activity.events.placed.fromSalesChannel", { - salesChannel: order.sales_channel.name, - })} + {getStylizedAmount(order.total, order.currency_code)} ), } @@ -311,7 +322,7 @@ const NoteBody = ({ note }: { note: Note }) => { author: name || email, }) - const { mutateAsync } = useAdminDeleteNote(note.id) + const { mutateAsync } = {} // useAdminDeleteNote(note.id) const handleDelete = async () => { const res = await prompt({ @@ -362,44 +373,21 @@ const NoteBody = ({ note }: { note: Note }) => { const FulfillmentCreatedBody = ({ fulfillment, }: { - fulfillment: Fulfillment + fulfillment: AdminFulfillment }) => { const { t } = useTranslation() - const { stock_location, isLoading, isError, error } = useStockLocation( - fulfillment.location_id!, - undefined, - { - enabled: !!fulfillment.location_id, - } - ) - const numberOfItems = fulfillment.items.reduce((acc, item) => { return acc + item.quantity }, 0) - const triggerText = stock_location - ? t("orders.activity.events.fulfillment.itemsFulfilledFrom", { - count: numberOfItems, - location: stock_location.name, - }) - : t("orders.activity.events.fulfillment.itemsFulfilled", { - count: numberOfItems, - }) - - if (isError) { - throw error - } - return (
- {isLoading ? ( - - ) : ( - - {triggerText} - - )} + + {t("orders.activity.events.fulfillment.items", { + count: numberOfItems, + })} +
) } diff --git a/packages/admin-next/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx b/packages/admin-next/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx index 8a648fe25a..7cbf0e5c14 100644 --- a/packages/admin-next/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx +++ b/packages/admin-next/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx @@ -192,14 +192,9 @@ const CostBreakdown = ({ order }: { order: AdminOrder }) => { return (
- DISCOUNTS link + // TODO: DISCOUNTS -> moved to line items now // secondaryValue={ // order.discounts.length > 0 // ? order.discounts.map((d) => d.code).join(", ") @@ -213,22 +208,9 @@ const CostBreakdown = ({ order }: { order: AdminOrder }) => { /> SHIPPING link - // secondaryValue={order.shipping_methods - // .map((sm) => sm.shipping_option.name) - // .join(", ")} + secondaryValue={order.shipping_methods.map((sm) => sm.name).join(", ")} value={getLocaleAmount(order.shipping_total, order.currency_code)} /> -
) } @@ -237,13 +219,23 @@ const Total = ({ order }: { order: AdminOrder }) => { const { t } = useTranslation() return ( -
- - {t("fields.total")} - - - {getStylizedAmount(order.total, order.currency_code)} - +
+
+ + {t("fields.total")} + + + {getStylizedAmount(order.total, order.currency_code)} + +
+
+ + {t("fields.paidTotal")} + + + {/*TODO*/}- + +
) } diff --git a/packages/admin-next/dashboard/src/routes/orders/order-detail/constants.ts b/packages/admin-next/dashboard/src/routes/orders/order-detail/constants.ts index cc63b01d98..7dad163f0a 100644 --- a/packages/admin-next/dashboard/src/routes/orders/order-detail/constants.ts +++ b/packages/admin-next/dashboard/src/routes/orders/order-detail/constants.ts @@ -2,6 +2,7 @@ const DEFAULT_PROPERTIES = [ "id", "status", "created_at", + "canceled_at", "email", // "payment_status", // -> TODO replacement for this "display_id", @@ -22,6 +23,7 @@ const DEFAULT_RELATIONS = [ "*billing_address", "*sales_channel", "*promotion", + "*shipping_methods", "*fulfillments", "*fulfillments.items", "*fulfillments.labels",