From c27aa46939f9dec6e57c7befbe7f3a582f2d5d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frane=20Poli=C4=87?= <16856471+fPolic@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:46:48 +0200 Subject: [PATCH] feat(dashboard): add inventory kit info in order summary (#8990) **What** - display inventory kit if the items' variant has one --- ![Screenshot 2024-09-04 at 14 12 07](https://github.com/user-attachments/assets/79053e4f-6100-4ab6-a72a-45fabcaa49bf) --- .../dashboard/src/i18n/translations/en.json | 3 +- .../order-summary-section.tsx | 64 ++++++++++++++++++- .../routes/orders/order-detail/constants.ts | 2 + 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/packages/admin/dashboard/src/i18n/translations/en.json b/packages/admin/dashboard/src/i18n/translations/en.json index 5dfc3b1d6e..95dccebaf8 100644 --- a/packages/admin/dashboard/src/i18n/translations/en.json +++ b/packages/admin/dashboard/src/i18n/translations/en.json @@ -844,7 +844,8 @@ "requestReturn": "Request return", "allocateItems": "Allocate items", "editOrder": "Edit order", - "editOrderContinue": "Continue order edit" + "editOrderContinue": "Continue order edit", + "inventoryKit": "Consists of {{count}}x inventory items" }, "payment": { "title": "Payments", diff --git a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx index c2a209ac04..0d5aebf2ad 100644 --- a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx +++ b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx @@ -1,4 +1,4 @@ -import { useMemo } from "react" +import { useMemo, useState } from "react" import { useTranslation } from "react-i18next" import { useNavigate } from "react-router-dom" @@ -10,6 +10,7 @@ import { DocumentText, ExclamationCircle, PencilSquare, + TriangleDownMini, } from "@medusajs/icons" import { AdminClaim, @@ -386,6 +387,8 @@ const Item = ({ const { t } = useTranslation() const isInventoryManaged = item.variant?.manage_inventory + const hasInventoryKit = (item.variant.inventory_items?.length || 0) > 1 + return ( <>
+ {hasInventoryKit && } + {returns.map((r) => ( ))} @@ -575,6 +580,63 @@ const CostBreakdown = ({ order }: { order: AdminOrder }) => { ) } +const InventoryKitBreakdown = ({ item }: { item: AdminOrderLineItem }) => { + const { t } = useTranslation() + + const [isOpen, setIsOpen] = useState(false) + + const inventory = item.variant.inventory_items + + return ( + <> +
setIsOpen((o) => !o)} + className="flex cursor-pointer items-center gap-2 border-t border-dashed px-6 py-4" + > + + + {t("orders.summary.inventoryKit", { count: inventory.length })} + +
+ {isOpen && ( +
+ {inventory.map((i) => { + return ( +
+
+ + {i.inventory.title} + + {i.inventory.sku && ( + + {" "} + ⋅ {i.inventory.sku} + + )} + +
+
+
+
+ + {i.required_quantity}x + +
+ ) + })} +
+ )} + + ) +} + const ReturnBreakdownWithDamages = ({ orderReturn, itemId, diff --git a/packages/admin/dashboard/src/routes/orders/order-detail/constants.ts b/packages/admin/dashboard/src/routes/orders/order-detail/constants.ts index feef070946..cfa1993d31 100644 --- a/packages/admin/dashboard/src/routes/orders/order-detail/constants.ts +++ b/packages/admin/dashboard/src/routes/orders/order-detail/constants.ts @@ -24,6 +24,8 @@ const DEFAULT_RELATIONS = [ "*items.variant.product", "*items.variant.options", "+items.variant.manage_inventory", + "*items.variant.inventory_items.inventory", + "+items.variant.inventory_items.required_quantity", "+summary", "*shipping_address", "*billing_address",