fix(medusa, admin-ui): List all inventory levels (#3552)
* ensure that all levels are listed * add changeset * remove count from config * update changeset version bump --------- Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
co-authored by
Oliver Windall Juhl
parent
cd54c7dca9
commit
0695ff642b
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa): remove limit of the number of levels to list when joining levels
|
||||||
+4
-3
@@ -38,9 +38,6 @@ const EditVariantInventoryModal = ({ onClose, product, variant }: Props) => {
|
|||||||
refetch,
|
refetch,
|
||||||
} = useAdminVariantsInventory(variant.id)
|
} = useAdminVariantsInventory(variant.id)
|
||||||
|
|
||||||
const variantInventoryItem = variantInventory?.inventory[0]
|
|
||||||
const itemId = variantInventoryItem?.id
|
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
onClose()
|
onClose()
|
||||||
}
|
}
|
||||||
@@ -50,6 +47,10 @@ const EditVariantInventoryModal = ({ onClose, product, variant }: Props) => {
|
|||||||
const onSubmit = async (data: EditFlowVariantFormType) => {
|
const onSubmit = async (data: EditFlowVariantFormType) => {
|
||||||
const locationLevels = data.stock.location_levels || []
|
const locationLevels = data.stock.location_levels || []
|
||||||
const manageInventory = data.stock.manage_inventory
|
const manageInventory = data.stock.manage_inventory
|
||||||
|
|
||||||
|
const variantInventoryItem = variantInventory?.inventory?.[0]
|
||||||
|
const itemId = variantInventoryItem?.id
|
||||||
|
|
||||||
delete data.stock.manage_inventory
|
delete data.stock.manage_inventory
|
||||||
delete data.stock.location_levels
|
delete data.stock.location_levels
|
||||||
|
|
||||||
|
|||||||
@@ -99,16 +99,9 @@ const InventoryTable: React.FC<InventoryTableProps> = () => {
|
|||||||
}, [store])
|
}, [store])
|
||||||
|
|
||||||
const {
|
const {
|
||||||
removeTab,
|
|
||||||
setTab,
|
|
||||||
saveTab,
|
|
||||||
availableTabs: filterTabs,
|
|
||||||
activeFilterTab,
|
|
||||||
reset,
|
reset,
|
||||||
paginate,
|
paginate,
|
||||||
setFilters,
|
|
||||||
setLocationFilter,
|
setLocationFilter,
|
||||||
filters,
|
|
||||||
setQuery: setFreeText,
|
setQuery: setFreeText,
|
||||||
queryObject,
|
queryObject,
|
||||||
representationObject,
|
representationObject,
|
||||||
@@ -120,11 +113,6 @@ const InventoryTable: React.FC<InventoryTableProps> = () => {
|
|||||||
const [query, setQuery] = useState(queryObject.query)
|
const [query, setQuery] = useState(queryObject.query)
|
||||||
const [numPages, setNumPages] = useState(0)
|
const [numPages, setNumPages] = useState(0)
|
||||||
|
|
||||||
const clearFilters = () => {
|
|
||||||
reset()
|
|
||||||
setQuery("")
|
|
||||||
}
|
|
||||||
|
|
||||||
const { inventory_items, isLoading, count } = useAdminInventoryItems(
|
const { inventory_items, isLoading, count } = useAdminInventoryItems(
|
||||||
{
|
{
|
||||||
...queryObject,
|
...queryObject,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
FilterableInventoryLevelProps,
|
||||||
IInventoryService,
|
IInventoryService,
|
||||||
InventoryItemDTO,
|
InventoryItemDTO,
|
||||||
InventoryLevelDTO,
|
InventoryLevelDTO,
|
||||||
@@ -25,9 +26,14 @@ export const getLevelsByInventoryItemId = async (
|
|||||||
locationIds: string[],
|
locationIds: string[],
|
||||||
inventoryService: IInventoryService
|
inventoryService: IInventoryService
|
||||||
): Promise<Record<string, LevelWithAvailability[]>> => {
|
): Promise<Record<string, LevelWithAvailability[]>> => {
|
||||||
const [levels] = await inventoryService.listInventoryLevels({
|
const selector: FilterableInventoryLevelProps = {
|
||||||
inventory_item_id: items.map((inventoryItem) => inventoryItem.id),
|
inventory_item_id: items.map((inventoryItem) => inventoryItem.id),
|
||||||
})
|
}
|
||||||
|
if (locationIds.length) {
|
||||||
|
selector.location_id = locationIds
|
||||||
|
}
|
||||||
|
|
||||||
|
const [levels] = await inventoryService.listInventoryLevels(selector, {})
|
||||||
|
|
||||||
const levelsWithAvailability: LevelWithAvailability[] = await Promise.all(
|
const levelsWithAvailability: LevelWithAvailability[] = await Promise.all(
|
||||||
levels.map(async (level) => {
|
levels.map(async (level) => {
|
||||||
|
|||||||
@@ -14,9 +14,12 @@ const joinSalesChannels = async (
|
|||||||
const salesChannelIds = await channelLocationService.listSalesChannelIds(
|
const salesChannelIds = await channelLocationService.listSalesChannelIds(
|
||||||
location.id
|
location.id
|
||||||
)
|
)
|
||||||
const [salesChannels] = await salesChannelService.listAndCount({
|
const [salesChannels] = await salesChannelService.listAndCount(
|
||||||
id: salesChannelIds,
|
{
|
||||||
})
|
id: salesChannelIds,
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
|
||||||
location.sales_channels = salesChannels
|
location.sales_channels = salesChannels
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user