feat(medusa, admin-ui, medusa-react, medusa-js): Allow toggling of manage inventory (#3435)

**What**
- Toggle manage inventory in the inventory management modal

**How**
- Create/update/remove inventory item based on if `manage_inventory` is set and if an inventory item already exists
- Move all stock location updates to when the modal is submitted
- Add create-inventory-item endpoint in the core

Fixes CORE-1196

Co-authored-by: Sebastian Rindom <7554214+srindom@users.noreply.github.com>
This commit is contained in:
Philip KorsholmandSebastian Rindom authored and GitHub committed 2023-03-14 16:14:31 +00:00
1 parent 30a3203640
commit fe9eea4c18
18 files changed
+844 -219

No files matched your search

@@ -9,6 +9,8 @@ import {
AdminInventoryItemsListWithVariantsAndLocationLevelsRes,
AdminInventoryItemsLocationLevelsRes,
AdminPostInventoryItemsItemLocationLevelsReq,
AdminPostInventoryItemsReq,
AdminPostInventoryItemsParams,
} from "@medusajs/medusa"
import { ResponsePromise } from "../../typings"
import BaseResource from "../base"
@@ -75,6 +77,28 @@ class AdminInventoryItemsResource extends BaseResource {
return this.client.request("DELETE", path, undefined, {}, customHeaders)
}
/**
* Create an Inventory Item
* @experimental This feature is under development and may change in the future.
* To use this feature please install @medusajs/inventory
* @description creates an Inventory Item
* @returns the created Inventory Item
*/
create(
payload: AdminPostInventoryItemsReq,
query?: AdminPostInventoryItemsParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminInventoryItemsRes> {
let path = `/admin/inventory-items`
if (query) {
const queryString = qs.stringify(query)
path += `?${queryString}`
}
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* Retrieve a list of Inventory Items
* @experimental This feature is under development and may change in the future.