mirror of
https://github.com/R0m1k3/Regisflow.git
synced 2026-10-24 07:38:18 +02:00
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
This commit is contained in:
1 parent
2377483fd7
commit
42b249e5b0
2 files changed
+10
-2
No files matched your search
@@ -281,7 +281,7 @@ export default function NewSaleForm({ onSaveSale }: NewSaleFormProps) {
|
|||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Quantité <span className="text-destructive">*</span></FormLabel>
|
<FormLabel>Quantité <span className="text-destructive">*</span></FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input type="number" min="1" placeholder="1" {...field} />
|
<Input type="number" min="1" placeholder="Entrez la quantité" {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|||||||
@@ -30,7 +30,15 @@ export function validateRequiredFields(formData: any): string[] {
|
|||||||
];
|
];
|
||||||
|
|
||||||
return requiredFields
|
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);
|
.map(field => field.label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user