feat(ui): streamline skeleton model selection and toast display
This commit is contained in:
@@ -146,15 +146,8 @@ const sanitizeSubComponents = (components: any[]): any[] => {
|
||||
const quantity = Number(component?.quantity)
|
||||
const normalizedQuantity = Number.isFinite(quantity) && quantity > 0 ? quantity : undefined
|
||||
|
||||
const customFields = sanitizeCustomFields(component?.customFields)
|
||||
const pieces = sanitizePieces(component?.pieces)
|
||||
const subComponents = sanitizeSubComponents(component?.subComponents)
|
||||
|
||||
const result: Record<string, unknown> = {
|
||||
name,
|
||||
customFields,
|
||||
pieces,
|
||||
subComponents,
|
||||
}
|
||||
|
||||
if (description !== undefined) {
|
||||
@@ -170,6 +163,14 @@ const sanitizeSubComponents = (components: any[]): any[] => {
|
||||
result.typeComposantLabel = typeComposantLabel
|
||||
}
|
||||
|
||||
const nestedSubComponents = sanitizeSubComponents(component?.subComponents)
|
||||
if (nestedSubComponents.length > 0) {
|
||||
result.subComponents = nestedSubComponents
|
||||
} else {
|
||||
result.subComponents = []
|
||||
}
|
||||
|
||||
// Sub components only carry structural info (they will be resolved via their own models)
|
||||
return result
|
||||
})
|
||||
.filter(Boolean)
|
||||
@@ -224,8 +225,8 @@ const hydrateSubComponents = (components: any[]): any[] => {
|
||||
quantity: component?.quantity ?? component?.quantite ?? undefined,
|
||||
typeComposantId: component?.typeComposantId ?? component?.typeComposant?.id ?? '',
|
||||
typeComposantLabel: component?.typeComposantLabel ?? component?.typeComposant?.name ?? '',
|
||||
customFields: hydrateCustomFields(component?.customFields),
|
||||
pieces: hydratePieces(component?.pieces),
|
||||
customFields: [],
|
||||
pieces: [],
|
||||
subComponents: hydrateSubComponents(component?.subComponents),
|
||||
}))
|
||||
}
|
||||
@@ -285,8 +286,8 @@ const mapSubComponents = (components: any[]): any[] => {
|
||||
quantity: component?.quantity ?? component?.quantite ?? undefined,
|
||||
typeComposantId: component?.typeComposantId ?? component?.typeComposant?.id ?? '',
|
||||
typeComposantLabel: component?.typeComposantLabel ?? component?.typeComposant?.name ?? '',
|
||||
customFields: mapComponentCustomFields(component?.customFields),
|
||||
pieces: mapComponentPieces(component?.pieces),
|
||||
customFields: [],
|
||||
pieces: [],
|
||||
subComponents: mapSubComponents(component?.subComponents),
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user