Fix/minor mw fixes (#3521)

**What**
- Fix stock locations quantities being shown as `undefined` and `NaN`
- Throw if updates to location levels are made with negative quantities through the api
- Show "allocated" in order summary for partially fulfilled orders

Fixes CORE-1268, CORE-1267, CORE-1265
This commit is contained in:
Philip Korsholm
2023-03-19 21:28:59 +01:00
committed by GitHub
parent a3a7ace0c0
commit ea2633bccf
5 changed files with 53 additions and 12 deletions

View File

@@ -456,6 +456,8 @@ const AdjustAvailabilityModal = ({
onChange={(e) => setStockedQuantity(e.target.valueAsNumber)}
autoFocus
type="number"
placeholder="0"
min={0}
value={stockedQuantity}
/>
</div>

View File

@@ -56,7 +56,8 @@ const SummaryCard: React.FC<SummaryCardProps> = ({ order, reservations }) => {
return (
item.quantity === item.fulfilled_quantity ||
(reservations &&
sum(reservations.map((r) => r.quantity)) === item.quantity)
sum(reservations.map((r) => r.quantity)) ===
item.quantity - (item.fulfilled_quantity || 0))
)
})
}, [reservationItemsMap, order])

View File

@@ -1,15 +1,16 @@
import React, { useMemo, useState, useContext } from "react"
import Modal from "../../../../../components/molecules/modal"
import { LayeredModalContext } from "../../../../../components/molecules/modal/layered-modal"
import { useAdminStockLocations } from "medusa-react"
import { InventoryLevelDTO, StockLocationDTO } from "@medusajs/medusa"
import { Controller, useFieldArray } from "react-hook-form"
import Button from "../../../../../components/fundamentals/button"
import Switch from "../../../../../components/atoms/switch"
import InputField from "../../../../../components/molecules/input"
import { NestedForm } from "../../../../../utils/nested-form"
import IconBadge from "../../../../../components/fundamentals/icon-badge"
import { InventoryLevelDTO, StockLocationDTO } from "@medusajs/medusa"
import React, { useContext, useMemo, useState } from "react"
import BuildingsIcon from "../../../../../components/fundamentals/icons/buildings-icon"
import Button from "../../../../../components/fundamentals/button"
import IconBadge from "../../../../../components/fundamentals/icon-badge"
import InputField from "../../../../../components/molecules/input"
import { LayeredModalContext } from "../../../../../components/molecules/modal/layered-modal"
import Modal from "../../../../../components/molecules/modal"
import { NestedForm } from "../../../../../utils/nested-form"
import Switch from "../../../../../components/atoms/switch"
import { useAdminStockLocations } from "medusa-react"
export type VariantStockFormType = {
manage_inventory?: boolean
@@ -64,6 +65,7 @@ const VariantStockForm = ({ form, locationLevels }: Props) => {
append({
location_id: added,
stocked_quantity: locationLevelMap.get(added)?.stocked_quantity ?? 0,
reserved_quantity: locationLevelMap.get(added)?.reserved_quantity ?? 0,
})
})
}