From 44950d2239647b87ece81e24a54be140164e186b Mon Sep 17 00:00:00 2001 From: Michael SCHAL Date: Thu, 2 Apr 2026 09:38:30 +0200 Subject: [PATCH] feat: implement supplier management module with CRUD operations and optimistic updates --- client/src/pages/DlcPage.tsx | 11 ++++++----- client/src/pages/Suppliers.tsx | 13 +++++++++++++ client/src/pages/mobile/DlcPage.tsx | 9 +++++---- server/migrations.ts | 4 ++++ shared/schema.ts | 1 + 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/client/src/pages/DlcPage.tsx b/client/src/pages/DlcPage.tsx index 2ef3b00..24f2716 100644 --- a/client/src/pages/DlcPage.tsx +++ b/client/src/pages/DlcPage.tsx @@ -137,12 +137,13 @@ export default function DlcPage() { // Toujours mettre à jour le nom du produit form.setValue("productName", article.libelle1, { shouldValidate: true }); - // Matcher le fournisseur par nom - if (article.nom_fou_principal) { - const apiName = article.nom_fou_principal.toLowerCase().trim(); + // Matcher le fournisseur par codefou en priorité, sinon par nom + if (article.codefou_principal) { const matched = (suppliers as any[]).find((s: any) => - s.name.toLowerCase().trim().includes(apiName) || - apiName.includes(s.name.toLowerCase().trim()) + s.codefou && s.codefou.trim().toLowerCase() === article.codefou_principal.trim().toLowerCase() + ) || (suppliers as any[]).find((s: any) => + s.name.toLowerCase().trim().includes(article.nom_fou_principal?.toLowerCase().trim() || '') || + (article.nom_fou_principal?.toLowerCase().trim() || '').includes(s.name.toLowerCase().trim()) ); if (matched) { form.setValue("supplierId", matched.id, { shouldValidate: true }); diff --git a/client/src/pages/Suppliers.tsx b/client/src/pages/Suppliers.tsx index d4fb951..dfdbee2 100644 --- a/client/src/pages/Suppliers.tsx +++ b/client/src/pages/Suppliers.tsx @@ -43,6 +43,7 @@ export default function Suppliers() { name: "", contact: "", phone: "", + codefou: "", hasDlc: false, automaticReconciliation: false, requiresControl: false, @@ -198,6 +199,7 @@ export default function Suppliers() { name: "", contact: "", phone: "", + codefou: "", hasDlc: false, automaticReconciliation: false, requiresControl: false, @@ -236,6 +238,7 @@ export default function Suppliers() { name: supplier.name || "", contact: supplier.contact || "", phone: supplier.phone || "", + codefou: (supplier as any).codefou || "", hasDlc: supplier.hasDlc || false, automaticReconciliation: supplier.automaticReconciliation || false, requiresControl: supplier.requiresControl || false, @@ -528,6 +531,16 @@ export default function Suppliers() { /> +
+ + handleChange('codefou', e.target.value)} + placeholder="ex: FOU01" + /> +
+