update produit details
This commit is contained in:
parent
18f9d83e5a
commit
638af78e1f
@ -579,6 +579,7 @@ const loadProduct = async () => {
|
||||
|
||||
try {
|
||||
const response = await productStore.fetchProduct(productId.value);
|
||||
console.log("Product data loaded:", response);
|
||||
productData.value = response;
|
||||
|
||||
// Initialize form data with current product data
|
||||
@ -594,6 +595,7 @@ const loadProduct = async () => {
|
||||
};
|
||||
|
||||
const initializeFormData = (data) => {
|
||||
console.log("Initializing form data:", data);
|
||||
formData.value = {
|
||||
nom: data.nom || "",
|
||||
reference: data.reference || "",
|
||||
@ -609,6 +611,7 @@ const initializeFormData = (data) => {
|
||||
conditionnement_nom: data.conditionnement?.nom || "",
|
||||
conditionnement_quantite: data.conditionnement?.quantite?.toString() || "",
|
||||
};
|
||||
console.log("Form data initialized:", formData.value);
|
||||
validationErrors.value = {};
|
||||
};
|
||||
|
||||
@ -654,7 +657,12 @@ const saveProduct = async () => {
|
||||
conditionnement_unite: formData.value.unite || null,
|
||||
};
|
||||
|
||||
await productStore.updateProduct(productId.value, productDataToSave);
|
||||
console.log("Saving product data:", productDataToSave);
|
||||
|
||||
await productStore.updateProduct(
|
||||
parseInt(productId.value),
|
||||
productDataToSave
|
||||
);
|
||||
|
||||
// Refresh product data
|
||||
await loadProduct();
|
||||
@ -667,6 +675,7 @@ const saveProduct = async () => {
|
||||
|
||||
// Handle validation errors from Laravel
|
||||
if (err.response?.status === 422 && err.response?.data?.errors) {
|
||||
console.log("Validation errors:", err.response.data.errors);
|
||||
validationErrors.value = err.response.data.errors;
|
||||
} else {
|
||||
error.value =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user