feat(dashboard): add inventory kit info in order summary (#8990)
**What** - display inventory kit if the items' variant has one --- 
This commit is contained in:
1 parent
0573bb924a
commit
c27aa46939
3 files changed
+67
-2
No files matched your search
@@ -844,7 +844,8 @@
|
|||||||
"requestReturn": "Request return",
|
"requestReturn": "Request return",
|
||||||
"allocateItems": "Allocate items",
|
"allocateItems": "Allocate items",
|
||||||
"editOrder": "Edit order",
|
"editOrder": "Edit order",
|
||||||
"editOrderContinue": "Continue order edit"
|
"editOrderContinue": "Continue order edit",
|
||||||
|
"inventoryKit": "Consists of {{count}}x inventory items"
|
||||||
},
|
},
|
||||||
"payment": {
|
"payment": {
|
||||||
"title": "Payments",
|
"title": "Payments",
|
||||||
|
|||||||
+63
-1
@@ -1,4 +1,4 @@
|
|||||||
import { useMemo } from "react"
|
import { useMemo, useState } from "react"
|
||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
import { useNavigate } from "react-router-dom"
|
import { useNavigate } from "react-router-dom"
|
||||||
|
|
||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
DocumentText,
|
DocumentText,
|
||||||
ExclamationCircle,
|
ExclamationCircle,
|
||||||
PencilSquare,
|
PencilSquare,
|
||||||
|
TriangleDownMini,
|
||||||
} from "@medusajs/icons"
|
} from "@medusajs/icons"
|
||||||
import {
|
import {
|
||||||
AdminClaim,
|
AdminClaim,
|
||||||
@@ -386,6 +387,8 @@ const Item = ({
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const isInventoryManaged = item.variant?.manage_inventory
|
const isInventoryManaged = item.variant?.manage_inventory
|
||||||
|
|
||||||
|
const hasInventoryKit = (item.variant.inventory_items?.length || 0) > 1
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
@@ -452,6 +455,8 @@ const Item = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{hasInventoryKit && <InventoryKitBreakdown item={item} />}
|
||||||
|
|
||||||
{returns.map((r) => (
|
{returns.map((r) => (
|
||||||
<ReturnBreakdown key={r.id} orderReturn={r} itemId={item.id} />
|
<ReturnBreakdown key={r.id} orderReturn={r} itemId={item.id} />
|
||||||
))}
|
))}
|
||||||
@@ -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 (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
onClick={() => setIsOpen((o) => !o)}
|
||||||
|
className="flex cursor-pointer items-center gap-2 border-t border-dashed px-6 py-4"
|
||||||
|
>
|
||||||
|
<TriangleDownMini
|
||||||
|
style={{
|
||||||
|
transform: `rotate(${isOpen ? 0 : -90}deg)`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<span className="text-ui-fg-muted txt-small select-none">
|
||||||
|
{t("orders.summary.inventoryKit", { count: inventory.length })}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{isOpen && (
|
||||||
|
<div className="flex flex-col gap-1 px-6 pb-4">
|
||||||
|
{inventory.map((i) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={i.inventory.id}
|
||||||
|
className="flex items-center justify-between gap-x-2"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<span className="txt-small text-ui-fg-subtle font-medium">
|
||||||
|
{i.inventory.title}
|
||||||
|
|
||||||
|
{i.inventory.sku && (
|
||||||
|
<span className="text-ui-fg-subtle font-normal">
|
||||||
|
{" "}
|
||||||
|
⋅ {i.inventory.sku}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="relative flex-1">
|
||||||
|
<div className="bottom-[calc(50% - 2px)] absolute h-[1px] w-full border-b border-dashed" />
|
||||||
|
</div>
|
||||||
|
<span className="txt-small text-ui-fg-muted">
|
||||||
|
{i.required_quantity}x
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const ReturnBreakdownWithDamages = ({
|
const ReturnBreakdownWithDamages = ({
|
||||||
orderReturn,
|
orderReturn,
|
||||||
itemId,
|
itemId,
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ const DEFAULT_RELATIONS = [
|
|||||||
"*items.variant.product",
|
"*items.variant.product",
|
||||||
"*items.variant.options",
|
"*items.variant.options",
|
||||||
"+items.variant.manage_inventory",
|
"+items.variant.manage_inventory",
|
||||||
|
"*items.variant.inventory_items.inventory",
|
||||||
|
"+items.variant.inventory_items.required_quantity",
|
||||||
"+summary",
|
"+summary",
|
||||||
"*shipping_address",
|
"*shipping_address",
|
||||||
"*billing_address",
|
"*billing_address",
|
||||||
|
|||||||
Reference in new issue
Block a user