fix(piece) : persist slot quantity on blur and send prix as string
- Save composant piece slot quantity via PATCH on blur - Pass slotId through hierarchy and selection entries - Send prix as string (not number) to match backend expectation - Show quantity in view mode when > 1 - Allow quantity edit for all pieces (not just root-level) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -110,18 +110,18 @@ export function useMachineDetailUpdates(deps: UseMachineDetailUpdatesDeps) {
|
||||
const productId = updatedComponent.productId
|
||||
? String(updatedComponent.productId)
|
||||
: null
|
||||
const prix =
|
||||
const prixStr =
|
||||
updatedComponent.prix !== null &&
|
||||
updatedComponent.prix !== undefined &&
|
||||
String(updatedComponent.prix).trim() !== ''
|
||||
? Number(updatedComponent.prix)
|
||||
? String(updatedComponent.prix)
|
||||
: null
|
||||
|
||||
const result: any = await updateComposantApi(updatedComponent.id as string, {
|
||||
name: updatedComponent.name,
|
||||
reference: updatedComponent.reference,
|
||||
constructeurIds: cIds,
|
||||
prix: Number.isNaN(prix) ? null : prix,
|
||||
prix: prixStr,
|
||||
productId,
|
||||
} as any)
|
||||
if (result.success) {
|
||||
@@ -140,18 +140,18 @@ export function useMachineDetailUpdates(deps: UseMachineDetailUpdatesDeps) {
|
||||
updatedPiece.constructeur,
|
||||
)
|
||||
const productId = updatedPiece.productId ? String(updatedPiece.productId) : null
|
||||
const prix =
|
||||
const prixStr =
|
||||
updatedPiece.prix !== null &&
|
||||
updatedPiece.prix !== undefined &&
|
||||
String(updatedPiece.prix).trim() !== ''
|
||||
? Number(updatedPiece.prix)
|
||||
? String(updatedPiece.prix)
|
||||
: null
|
||||
|
||||
const result: any = await updatePieceApi(updatedPiece.id as string, {
|
||||
name: updatedPiece.name,
|
||||
reference: updatedPiece.reference || null,
|
||||
constructeurIds: cIds,
|
||||
prix: Number.isNaN(prix) ? null : prix,
|
||||
prix: prixStr,
|
||||
productId,
|
||||
} as any)
|
||||
if (result.success) {
|
||||
@@ -181,6 +181,13 @@ export function useMachineDetailUpdates(deps: UseMachineDetailUpdatesDeps) {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Update slot quantity if this is a composant structure piece
|
||||
const slotId = updatedPiece.slotId as string | null
|
||||
const quantity = typeof updatedPiece.quantity === 'number' ? Math.max(1, updatedPiece.quantity) : null
|
||||
if (slotId && quantity !== null) {
|
||||
await apiPatch(`/composant-piece-slots/${slotId}`, { quantity })
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de la mise à jour de la pièce:', error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user