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