fix(admin-ui): Allow backorder update on variants (#4051)
This commit is contained in:
@@ -17,7 +17,7 @@ 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 { removeFalsy, removeNullish } from "../../../utils/remove-nullish"
|
||||
import { useContext } from "react"
|
||||
import useEditProductActions from "../../../hooks/use-edit-product-actions"
|
||||
import { useForm } from "react-hook-form"
|
||||
@@ -59,7 +59,7 @@ const EditVariantInventoryModal = ({ onClose, product, variant }: Props) => {
|
||||
delete data.upc
|
||||
delete data.allow_backorder
|
||||
|
||||
return removeNullish({
|
||||
return removeFalsy({
|
||||
...updateDimensions,
|
||||
...updateCustoms,
|
||||
...data,
|
||||
@@ -167,15 +167,17 @@ const EditVariantInventoryModal = ({ onClose, product, variant }: Props) => {
|
||||
// @ts-ignore
|
||||
onUpdateVariant(
|
||||
variant.id,
|
||||
removeNullish({
|
||||
...dimensions,
|
||||
...customs,
|
||||
...stock,
|
||||
ean,
|
||||
barcode,
|
||||
upc,
|
||||
allow_backorder,
|
||||
}),
|
||||
{
|
||||
...removeNullish({
|
||||
...dimensions,
|
||||
...customs,
|
||||
...stock,
|
||||
ean,
|
||||
barcode,
|
||||
upc,
|
||||
allow_backorder,
|
||||
}),
|
||||
},
|
||||
() => {
|
||||
refetch()
|
||||
if (shouldInvalidateCache) {
|
||||
@@ -287,7 +289,7 @@ export const getEditVariantDefaultValues = (
|
||||
upc: variant?.upc || null,
|
||||
inventory_quantity: null,
|
||||
manage_inventory: false,
|
||||
allow_backorder: false,
|
||||
allow_backorder: variant?.allow_backorder ?? false,
|
||||
location_levels: null,
|
||||
dimensions: {
|
||||
height: null,
|
||||
@@ -325,7 +327,7 @@ export const getEditVariantDefaultValues = (
|
||||
upc: variant?.upc || null,
|
||||
inventory_quantity: inventoryItem.inventory_quantity,
|
||||
manage_inventory: !!inventoryItem,
|
||||
allow_backorder: inventoryItem.allow_backorder,
|
||||
allow_backorder: !!variant?.allow_backorder,
|
||||
location_levels: inventoryItem.location_levels,
|
||||
dimensions: {
|
||||
height: inventoryItem.height,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useAdminCreateDiscount } from "medusa-react"
|
||||
import { useNavigate } from "react-router-dom"
|
||||
import useNotification from "../../../hooks/use-notification"
|
||||
import { getErrorMessage } from "../../../utils/error-messages"
|
||||
import { removeNullish } from "../../../utils/remove-nullish"
|
||||
import { removeFalsy } from "../../../utils/remove-nullish"
|
||||
|
||||
const useCopyPromotion = () => {
|
||||
const navigate = useNavigate()
|
||||
@@ -47,7 +47,7 @@ const useCopyPromotion = () => {
|
||||
if (promotion.rule.conditions) {
|
||||
copy.rule.conditions = promotion.rule.conditions.map((cond) => ({
|
||||
operator: cond.operator,
|
||||
...removeNullish({
|
||||
...removeFalsy({
|
||||
products: cond.products,
|
||||
product_types: cond.product_types,
|
||||
product_tags: cond.product_tags,
|
||||
|
||||
Reference in New Issue
Block a user