add stock
This commit is contained in:
@@ -46,7 +46,9 @@ const UpdateProduct: FC = () => {
|
||||
images: [],
|
||||
discount: 0,
|
||||
isSpecialOffer: false,
|
||||
order: 0
|
||||
order: 0,
|
||||
stock: undefined,
|
||||
maxPurchaseQuantity: undefined
|
||||
},
|
||||
validationSchema: Yup.object().shape({
|
||||
title: Yup.string().required('نام کالا الزامی است'),
|
||||
@@ -75,9 +77,10 @@ const UpdateProduct: FC = () => {
|
||||
? values.variants.map((v) => ({
|
||||
...(v.id && { id: v.id }),
|
||||
value: v.value ?? '',
|
||||
price: v.price ?? 0
|
||||
price: v.price ?? 0,
|
||||
...(v.stock !== undefined && v.stock !== null && { stock: v.stock })
|
||||
}))
|
||||
: [{ value: '', price: values.price }]
|
||||
: [{ value: '', price: values.price, ...(values.stock !== undefined && values.stock !== null && { stock: values.stock }) }]
|
||||
const productData: CreateProductType = {
|
||||
...values,
|
||||
variants,
|
||||
@@ -130,7 +133,9 @@ const UpdateProduct: FC = () => {
|
||||
images: product.images || [],
|
||||
discount: product.discount || 0,
|
||||
isSpecialOffer: product.isSpecialOffer || false,
|
||||
order: product.order ?? 0
|
||||
order: product.order ?? 0,
|
||||
stock: product.variants?.[0]?.stock,
|
||||
maxPurchaseQuantity: product.maxPurchaseQuantity
|
||||
})
|
||||
setIsActive(product.isActive || false)
|
||||
setIsSpecial(product.isSpecialOffer || false)
|
||||
|
||||
Reference in New Issue
Block a user