Skip to content

Commit

Permalink
fix(admin-ui): Hide create fulfilment button when nothing left to ful…
Browse files Browse the repository at this point in the history
…fil (#3515)

Previously, if an order had two fulfilments that fully satisfied the order, then only one was shipped, the status would change to `partially_shipped` and show the "Create Fulfillment" button again, which would open a buggy modal with no items to fulfil. Added another check that looks at the items in the order and compares `quantity` and `fulfilled_quantity`, so that we can hide the button based on this as well, rather than just the order's `fulfillment_status`, which can be misleading.

Also added a status icon to the Fulfillment card's title bar for the `partially_shipped` status, as this area was blank before in that state.

Resolves CORE-1262
  • Loading branch information
StephixOne authored Mar 20, 2023
1 parent 026bdab commit 2176ff5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/admin-ui/ui/src/domain/orders/details/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { Address, ClaimOrder, Fulfillment, Swap } from "@medusajs/medusa"
import {
Address,
ClaimOrder,
Fulfillment,
LineItem,
Swap,
} from "@medusajs/medusa"
import {
DisplayTotal,
FormattedAddress,
Expand Down Expand Up @@ -261,6 +267,10 @@ const OrderDetails = () => {
navigate("/404")
}

const anyItemsToFulfil = order.items.some(
(item: LineItem) => item.quantity > (item.fulfilled_quantity ?? 0)
)

return (
<div>
<OrderEditProvider orderId={id!}>
Expand Down Expand Up @@ -415,9 +425,8 @@ const OrderDetails = () => {
/>
}
customActionable={
order.fulfillment_status !== "fulfilled" &&
order.status !== "canceled" &&
order.fulfillment_status !== "shipped" && (
anyItemsToFulfil && (
<Button
variant="secondary"
size="small"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const FulfillmentStatusComponent = ({ status }) => {
return <StatusDot title="Requires Action" variant="danger" />
case "not_fulfilled":
return <StatusDot title="Awaiting fulfillment" variant="danger" />
case "partially_shipped":
return <StatusDot title="Partially Shipped" variant="warning" />
default:
return null
}
Expand Down

0 comments on commit 2176ff5

Please sign in to comment.