chore: build
This commit is contained in:
@@ -644,6 +644,17 @@ export const updateProductAdmin = async (
|
||||
return { success: true, data: data.data, message: data.message };
|
||||
};
|
||||
|
||||
export const updateProductStockAdmin = async (
|
||||
productId: number,
|
||||
stock: number,
|
||||
) => {
|
||||
const { data } = await apiClient.post(
|
||||
`${V2}/admin/protected/products/${productId}/stock`,
|
||||
{ stock },
|
||||
);
|
||||
return { success: true, product: data.product };
|
||||
};
|
||||
|
||||
export const deleteProductAdmin = async (productId: number) => {
|
||||
const { data } = await apiClient.delete(
|
||||
`${V2}/admin/protected/products/${productId}`,
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
getAllProductsAdmin,
|
||||
createProductAdmin,
|
||||
updateProductAdmin,
|
||||
updateProductStockAdmin,
|
||||
deleteProductAdmin,
|
||||
uploadProductMediaAdmin,
|
||||
deleteProductMediaAdmin,
|
||||
@@ -334,16 +335,20 @@ export default function ProductsScreen() {
|
||||
}
|
||||
}
|
||||
|
||||
// 2) Update product fields
|
||||
// 2) Update product fields (sans le stock : il n'écrase pas les ventes en cours)
|
||||
await updateProductAdmin(editingProduct.id, {
|
||||
name: form.name.trim(),
|
||||
category: form.category,
|
||||
description: form.description.trim(),
|
||||
stock: parseFloat(form.stock),
|
||||
unit: form.unit,
|
||||
prices,
|
||||
coming_soon: form.comingSoon,
|
||||
});
|
||||
|
||||
const newStock = parseFloat(form.stock);
|
||||
if (newStock !== editingProduct.stock) {
|
||||
await updateProductStockAdmin(editingProduct.id, newStock);
|
||||
}
|
||||
productId = editingProduct.id;
|
||||
} else {
|
||||
// ✅ FIX : Création avec FormData au bon format pour le backend Go
|
||||
|
||||
Reference in New Issue
Block a user