feat(admin-ui): Manage inventory toggle (#4041)

This commit is contained in:
Philip Korsholm
2023-05-08 18:44:27 +02:00
committed by GitHub
parent 1ea57c3a69
commit 353fc94e4f
2 changed files with 10 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"@medusajs/admin-ui": patch
---
fix(admin-ui): toggle manage inventory

View File

@@ -14,13 +14,13 @@ import {
import Button from "../../fundamentals/button"
import { InventoryLevelDTO } from "@medusajs/types"
import Modal from "../../molecules/modal"
import { Option } from "../../../types/shared"
import { countries } from "../../../utils/countries"
import { queryClient } from "../../../constants/query-client"
import { removeNullish } from "../../../utils/remove-nullish"
import { useContext } from "react"
import useEditProductActions from "../../../hooks/use-edit-product-actions"
import { useForm } from "react-hook-form"
import { countries } from "../../../utils/countries"
import { Option } from "../../../types/shared"
type Props = {
onClose: () => void
@@ -120,6 +120,9 @@ const EditVariantInventoryModal = ({ onClose, product, variant }: Props) => {
await client.admin.inventoryItems.update(itemId!, upsertPayload)
}
} else if (manageInventory) {
await client.admin.products.updateVariant(product.id, variant.id, {
manage_inventory: true,
})
// does not have an inventory item but wants to manage inventory
const { inventory_item } = await client.admin.inventoryItems.create({
variant_id: variant.id,