fix(admin-ui): allocated badge for orders with statuses cancelled and archived (#3950)

* fix allocated badge for orders with statuses cancelled and archived

* add changeset
This commit is contained in:
Philip Korsholm authored and GitHub committed 2023-05-01 09:48:51 +02:00
1 parent 163cd686f9
commit 0c30d05cf3
3 files changed
+27 -5

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@medusajs/admin-ui": patch
---
fix(admin-ui): allocation status for cancelled and archived orders
@@ -164,6 +164,8 @@ const SummaryCard: React.FC<SummaryCardProps> = ({ order, reservations }) => {
return actionables return actionables
}, [showModal, isFeatureEnabled, showAllocationModal, allItemsReserved]) }, [showModal, isFeatureEnabled, showAllocationModal, allItemsReserved])
const isAllocatable = !["canceled", "archived"].includes(order.status)
return ( return (
<BodyCard <BodyCard
className={"mb-4 h-auto min-h-0 w-full"} className={"mb-4 h-auto min-h-0 w-full"}
@@ -172,9 +174,17 @@ const SummaryCard: React.FC<SummaryCardProps> = ({ order, reservations }) => {
isFeatureEnabled("inventoryService") && isFeatureEnabled("inventoryService") &&
Array.isArray(reservations) && ( Array.isArray(reservations) && (
<StatusIndicator <StatusIndicator
onClick={allItemsReserved ? undefined : showAllocationModal} onClick={
variant={allItemsReserved ? "success" : "danger"} allItemsReserved || !isAllocatable
title={allItemsReserved ? "Allocated" : "Awaits allocation"} ? undefined
: showAllocationModal
}
variant={allItemsReserved || !isAllocatable ? "success" : "danger"}
title={
allItemsReserved || !isAllocatable
? "Allocated"
: "Awaits allocation"
}
className="rounded-rounded border px-3 py-1.5" className="rounded-rounded border px-3 py-1.5"
/> />
) )
@@ -188,6 +198,7 @@ const SummaryCard: React.FC<SummaryCardProps> = ({ order, reservations }) => {
item={item} item={item}
currencyCode={order.currency_code} currencyCode={order.currency_code}
reservations={reservationItemsMap[item.id]} reservations={reservationItemsMap[item.id]}
isAllocatable={isAllocatable}
/> />
))} ))}
<DisplayTotal <DisplayTotal
@@ -10,9 +10,15 @@ type OrderLineProps = {
item: LineItem item: LineItem
currencyCode: string currencyCode: string
reservations?: ReservationItemDTO[] reservations?: ReservationItemDTO[]
isAllocatable?: boolean
} }
const OrderLine = ({ item, currencyCode, reservations }: OrderLineProps) => { const OrderLine = ({
item,
currencyCode,
reservations,
isAllocatable = true,
}: OrderLineProps) => {
const { isFeatureEnabled } = useFeatureFlag() const { isFeatureEnabled } = useFeatureFlag()
return ( return (
<div className="hover:bg-grey-5 rounded-rounded mx-[-5px] mb-1 flex h-[64px] justify-between py-2 px-[5px]"> <div className="hover:bg-grey-5 rounded-rounded mx-[-5px] mb-1 flex h-[64px] justify-between py-2 px-[5px]">
@@ -50,7 +56,7 @@ const OrderLine = ({ item, currencyCode, reservations }: OrderLineProps) => {
<div className="inter-small-regular text-grey-50"> <div className="inter-small-regular text-grey-50">
x {item.quantity} x {item.quantity}
</div> </div>
{isFeatureEnabled("inventoryService") && ( {isFeatureEnabled("inventoryService") && isAllocatable && (
<ReservationIndicator reservations={reservations} lineItem={item} /> <ReservationIndicator reservations={reservations} lineItem={item} />
)} )}
<div className="inter-small-regular text-grey-90 min-w-[55px] text-right"> <div className="inter-small-regular text-grey-90 min-w-[55px] text-right">