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:
co-authored by
Sebastian Rindom
parent
30a3203640
commit
fe9eea4c18
@@ -4,6 +4,8 @@ import {
|
||||
AdminPostInventoryItemsInventoryItemReq,
|
||||
AdminPostInventoryItemsItemLocationLevelsLevelReq,
|
||||
AdminPostInventoryItemsItemLocationLevelsReq,
|
||||
AdminPostInventoryItemsReq,
|
||||
AdminPostInventoryItemsParams
|
||||
} from "@medusajs/medusa"
|
||||
import { Response } from "@medusajs/medusa-js"
|
||||
import {
|
||||
@@ -17,6 +19,29 @@ import { adminInventoryItemsKeys } from "./queries"
|
||||
|
||||
// inventory item
|
||||
|
||||
// create inventory item
|
||||
export const useAdminCreateInventoryItem = (
|
||||
options?: UseMutationOptions<
|
||||
Response<AdminInventoryItemsRes>,
|
||||
Error,
|
||||
AdminPostInventoryItemsReq
|
||||
>
|
||||
) => {
|
||||
const { client } = useMedusa()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation(
|
||||
(payload: AdminPostInventoryItemsReq, query?: AdminPostInventoryItemsParams) =>
|
||||
client.admin.inventoryItems.create(payload, query),
|
||||
buildOptions(
|
||||
queryClient,
|
||||
[adminInventoryItemsKeys.lists()],
|
||||
options
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
// update inventory item
|
||||
export const useAdminUpdateInventoryItem = (
|
||||
inventoryItemId: string,
|
||||
|
||||
Reference in New Issue
Block a user