WIP: corrections multiples formulaires et sérialisation

- Fix constructeurUtils: réordonner delete/add pour sauvegarder les fournisseurs
- Fix prix/supplierPrice: envoyer en string pour DECIMAL Doctrine
- Fix useMachineTypesApi: normaliser les requirements et forceRefresh
- Fix SearchSelect: watch deep sur baseOptions
- Debug logs temporaires pour pieceRequirements

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-23 12:28:40 +01:00
parent 2f3d4c5260
commit 9cc7ac10f0
14 changed files with 276 additions and 89 deletions

View File

@@ -117,21 +117,48 @@ export const formatConstructeurContact = (
export const buildConstructeurRequestPayload = <T extends Record<string, any>>(
payload: T,
): T & { constructeurs?: string[] } => {
const ids = uniqueConstructeurIds(
const collected = new Set(uniqueConstructeurIds(
payload?.constructeurIds,
payload?.constructeurId,
payload?.constructeur,
payload?.constructeurs,
);
));
if (!collected.size) {
const fallbackLists = [
payload?.constructeurIds,
payload?.constructeurs,
];
fallbackLists.forEach((list) => {
if (!Array.isArray(list)) {
return;
}
list.forEach((item) => {
if (typeof item === 'string') {
const id = toStringId(item);
if (id) {
collected.add(id);
}
return;
}
if (isObject(item) && typeof item.id === 'string') {
collected.add(item.id);
}
});
});
}
const ids = Array.from(collected);
const next = { ...payload } as Record<string, any>;
if (ids.length) {
next.constructeurs = ids.map((id) => `/api/constructeurs/${id}`);
}
delete next.constructeurId;
delete next.constructeur;
delete next.constructeurs;
delete next.constructeurIds;
if (ids.length) {
next.constructeurs = ids.map((id) => `/api/constructeurs/${id}`);
}
return next as T & { constructeurs?: string[] };
};