feat: gérer les constructeurs multiples

This commit is contained in:
Matthieu
2025-10-28 16:37:10 +01:00
parent da447e4ea2
commit b752fba69a
14 changed files with 901 additions and 222 deletions

View File

@@ -11,6 +11,7 @@ import {
type PieceModelStructureForEditor,
createEmptyPieceModelStructure,
} from './types/inventory'
import { uniqueConstructeurIds } from './constructeurUtils'
export const isPlainObject = (value: unknown): value is Record<string, unknown> => {
return value !== null && typeof value === 'object' && !Array.isArray(value)
@@ -686,7 +687,7 @@ export const formatStructurePreview = (structure: any) => {
export interface DefinitionOverridePayload {
name?: string
reference?: string
constructeurId?: string | null
constructeurIds?: string[]
prix?: number
}
@@ -711,8 +712,14 @@ export const sanitizeDefinitionOverrides = (definition: any): DefinitionOverride
}
}
if (definition.constructeurId !== undefined && definition.constructeurId !== null && definition.constructeurId !== '') {
payload.constructeurId = definition.constructeurId
const constructeurIds = uniqueConstructeurIds(
definition.constructeurIds,
definition.constructeurId,
definition.constructeur,
definition.constructeurs,
)
if (constructeurIds.length) {
payload.constructeurIds = constructeurIds
}
if (definition.prix !== undefined && definition.prix !== null && definition.prix !== '') {