diff --git a/app/composables/useComponentEdit.ts b/app/composables/useComponentEdit.ts index 36b0972..1f8ec31 100644 --- a/app/composables/useComponentEdit.ts +++ b/app/composables/useComponentEdit.ts @@ -313,9 +313,8 @@ export function useComponentEdit(componentId: string) { }) const savePieceSlotSelection = async (slotId: string, selectedPieceId: string | null) => { - try { - await patch(`/composant-piece-slots/${slotId}`, { selectedPieceId }) - // Update local structure + const result = await patch(`/composant-piece-slots/${slotId}`, { selectedPieceId }) + if (result.success) { const structure = component.value?.structure if (structure?.pieces) { const slot = (structure.pieces as any[]).find((s: any) => s.slotId === slotId) @@ -323,14 +322,11 @@ export function useComponentEdit(componentId: string) { } toast.showSuccess('Pièce mise à jour') } - catch (error: any) { - toast.showError(error?.message || 'Erreur lors de la mise à jour') - } } const saveProductSlotSelection = async (slotId: string, selectedProductId: string | null) => { - try { - await patch(`/composant-product-slots/${slotId}`, { selectedProductId }) + const result = await patch(`/composant-product-slots/${slotId}`, { selectedProductId }) + if (result.success) { const structure = component.value?.structure if (structure?.products) { const slot = (structure.products as any[]).find((s: any) => s.slotId === slotId) @@ -338,14 +334,11 @@ export function useComponentEdit(componentId: string) { } toast.showSuccess('Produit mis à jour') } - catch (error: any) { - toast.showError(error?.message || 'Erreur lors de la mise à jour') - } } const saveSubcomponentSlotSelection = async (slotId: string, selectedComposantId: string | null) => { - try { - await patch(`/composant-subcomponent-slots/${slotId}`, { selectedComposantId }) + const result = await patch(`/composant-subcomponent-slots/${slotId}`, { selectedComposantId }) + if (result.success) { const structure = component.value?.structure if (structure?.subcomponents) { const slot = (structure.subcomponents as any[]).find((s: any) => s.slotId === slotId) @@ -353,9 +346,6 @@ export function useComponentEdit(componentId: string) { } toast.showSuccess('Sous-composant mis à jour') } - catch (error: any) { - toast.showError(error?.message || 'Erreur lors de la mise à jour') - } } const saveSlotQuantity = async (entry: SelectionEntry) => {