Fix/disable allocate button (#3426)

* remove allocate option from order editing summary if no further allocations can be made

* add changeset

* add minor button styles to badge component
This commit is contained in:
Philip Korsholm
2023-03-09 13:05:56 +01:00
committed by GitHub
parent 478d1af8d0
commit 784723a039
3 changed files with 12 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@medusajs/admin-ui": patch
---
fix(admin-ui): remove allocate button if no more allcoations can be made
@@ -22,10 +22,12 @@ const StatusIndicator: React.FC<StatusIndicatorProps> = ({
}) })
return ( return (
<div <div
className={clsx("flex items-center inter-small-regular", className)} className={clsx("inter-small-regular flex items-center", className, {
"hover:bg-grey-5 cursor-pointer": !!props.onClick,
})}
{...props} {...props}
> >
<div className={clsx("w-1.5 h-1.5 self-center rounded-full", dotClass)} /> <div className={clsx("h-1.5 w-1.5 self-center rounded-full", dotClass)} />
{title && <span className="ml-2">{title}</span>} {title && <span className="ml-2">{title}</span>}
</div> </div>
) )
@@ -117,14 +117,14 @@ const SummaryCard: React.FC<SummaryCardProps> = ({
onClick: showModal, onClick: showModal,
}) })
} }
if (isFeatureEnabled("inventoryService")) { if (isFeatureEnabled("inventoryService") && !allItemsReserved) {
actionables.push({ actionables.push({
label: "Allocate", label: "Allocate",
onClick: showAllocationModal, onClick: showAllocationModal,
}) })
} }
return actionables return actionables
}, [showModal, isFeatureEnabled, showAllocationModal]) }, [showModal, isFeatureEnabled, showAllocationModal, allItemsReserved])
return ( return (
<BodyCard <BodyCard
@@ -134,6 +134,7 @@ const SummaryCard: React.FC<SummaryCardProps> = ({
isFeatureEnabled("inventoryService") && isFeatureEnabled("inventoryService") &&
Array.isArray(reservations) && ( Array.isArray(reservations) && (
<StatusIndicator <StatusIndicator
onClick={allItemsReserved ? undefined : showAllocationModal}
variant={allItemsReserved ? "success" : "danger"} variant={allItemsReserved ? "success" : "danger"}
title={allItemsReserved ? "Allocated" : "Awaits allocation"} title={allItemsReserved ? "Allocated" : "Awaits allocation"}
className="rounded-rounded border px-3 py-1.5" className="rounded-rounded border px-3 py-1.5"