From 42b249e5b0016830230046236dc270f91b01aec0 Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Wed, 9 Jul 2025 18:28:20 +0000 Subject: [PATCH] Improve form validation and guide users to fill out all the required fields Updates form validation logic to allow zero quantity and adds quantity placeholder. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 91318273-c764-4fd4-be04-bdc12c38af32 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/36c2c7b9-873e-432e-9d49-6ced2f07df49.jpg --- client/src/components/NewSaleForm.tsx | 2 +- client/src/lib/validation.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/client/src/components/NewSaleForm.tsx b/client/src/components/NewSaleForm.tsx index 1ef9b9e..0d8bdbf 100644 --- a/client/src/components/NewSaleForm.tsx +++ b/client/src/components/NewSaleForm.tsx @@ -281,7 +281,7 @@ export default function NewSaleForm({ onSaveSale }: NewSaleFormProps) { Quantité * - + diff --git a/client/src/lib/validation.ts b/client/src/lib/validation.ts index 1f30c2d..47041d5 100644 --- a/client/src/lib/validation.ts +++ b/client/src/lib/validation.ts @@ -30,7 +30,15 @@ export function validateRequiredFields(formData: any): string[] { ]; return requiredFields - .filter(field => !formData[field.key] || formData[field.key].toString().trim() === '') + .filter(field => { + const value = formData[field.key]; + // Pour la quantité, accepter 0 comme valeur valide + if (field.key === 'quantite') { + return value === '' || value === null || value === undefined; + } + // Pour les autres champs, vérifier si vide ou juste des espaces + return !value || value.toString().trim() === ''; + }) .map(field => field.label); }