feat: gérer les constructeurs multiples
This commit is contained in:
@@ -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 !== '') {
|
||||
|
||||
Reference in New Issue
Block a user