Require complete identity information and EAN13 code for each sale

Makes identity document information and EAN13 code mandatory in the `NewSaleForm.tsx`, updates validation in `validation.ts`, and adds `numeroIdentite` to `Sale` and `FormData` types.

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/e098e07a-77c2-4cd4-a935-0bcff4db12bf.jpg
This commit is contained in:
michaelschal committed 2025-07-09 18:11:09 +00:00
1 parent 4fac1078a1
commit cddfee5d09
4 files changed
+39 -16

No files matched your search

+28 -12
View File
@@ -37,6 +37,7 @@ export default function NewSaleForm({ onSaveSale }: NewSaleFormProps) {
dateNaissance: '',
lieuNaissance: '',
typeIdentite: '',
numeroIdentite: '',
autoriteDelivrance: '',
dateDelivrance: '',
}
@@ -96,11 +97,11 @@ export default function NewSaleForm({ onSaveSale }: NewSaleFormProps) {
return;
}
// Validate EAN13 if provided
if (data.gencode && !validateEAN13(data.gencode)) {
// Validate EAN13 (now required)
if (!validateEAN13(data.gencode)) {
toast({
title: "Code EAN13 invalide",
description: "Le code produit doit être un code EAN13 valide à 13 chiffres",
description: "Le gencode doit être un code EAN13 valide à 13 chiffres",
variant: "destructive",
});
return;
@@ -112,12 +113,13 @@ export default function NewSaleForm({ onSaveSale }: NewSaleFormProps) {
typeArticle: data.typeArticle,
categorie: data.categorie as 'F2' | 'F3',
quantite: parseInt(data.quantite),
gencode: data.gencode || undefined,
gencode: data.gencode,
nom: data.nom,
prenom: data.prenom,
dateNaissance: data.dateNaissance || undefined,
dateNaissance: data.dateNaissance,
lieuNaissance: data.lieuNaissance || undefined,
typeIdentite: data.typeIdentite || undefined,
typeIdentite: data.typeIdentite,
numeroIdentite: data.numeroIdentite,
autoriteDelivrance: data.autoriteDelivrance || undefined,
dateDelivrance: data.dateDelivrance || undefined,
photoRecto: photos.recto,
@@ -139,6 +141,7 @@ export default function NewSaleForm({ onSaveSale }: NewSaleFormProps) {
dateNaissance: '',
lieuNaissance: '',
typeIdentite: '',
numeroIdentite: '',
autoriteDelivrance: '',
dateDelivrance: '',
});
@@ -186,9 +189,9 @@ export default function NewSaleForm({ onSaveSale }: NewSaleFormProps) {
name="vendeur"
render={({ field }) => (
<FormItem>
<FormLabel>Nom du vendeur <span className="text-destructive">*</span></FormLabel>
<FormLabel>Vendeur <span className="text-destructive">*</span></FormLabel>
<FormControl>
<Input placeholder="Nom et prénom du vendeur" {...field} />
<Input placeholder="Vendeur" {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -286,9 +289,9 @@ export default function NewSaleForm({ onSaveSale }: NewSaleFormProps) {
name="gencode"
render={({ field }) => (
<FormItem>
<FormLabel>Code produit (EAN13)</FormLabel>
<FormLabel>Gencode (EAN13) <span className="text-destructive">*</span></FormLabel>
<FormControl>
<Input placeholder="Ex: 1234567890123" {...field} />
<Input placeholder="Code EAN13 à 13 chiffres" {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -348,7 +351,7 @@ export default function NewSaleForm({ onSaveSale }: NewSaleFormProps) {
name="dateNaissance"
render={({ field }) => (
<FormItem>
<FormLabel>Date de naissance</FormLabel>
<FormLabel>Date de naissance <span className="text-destructive">*</span></FormLabel>
<FormControl>
<Input type="date" {...field} />
</FormControl>
@@ -384,7 +387,7 @@ export default function NewSaleForm({ onSaveSale }: NewSaleFormProps) {
name="typeIdentite"
render={({ field }) => (
<FormItem>
<FormLabel>Type de pièce d'identité</FormLabel>
<FormLabel>Type de pièce d'identité <span className="text-destructive">*</span></FormLabel>
<Select value={field.value} onValueChange={field.onChange}>
<FormControl>
<SelectTrigger>
@@ -403,6 +406,19 @@ export default function NewSaleForm({ onSaveSale }: NewSaleFormProps) {
</FormItem>
)}
/>
<FormField
control={form.control}
name="numeroIdentite"
render={({ field }) => (
<FormItem>
<FormLabel>Numéro de pièce d'identité <span className="text-destructive">*</span></FormLabel>
<FormControl>
<Input placeholder="Numéro de la pièce d'identité" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="autoriteDelivrance"
@@ -66,6 +66,7 @@ export default function SaleDetailsModal({ isOpen, sale, onClose }: SaleDetailsM
<h4 className="font-medium text-gray-900 mb-2">Pièce d'Identité</h4>
<div className="grid grid-cols-2 gap-4 text-sm">
<div><span className="font-medium">Type:</span> {sale.typeIdentite || 'Non spécifié'}</div>
<div><span className="font-medium">Numéro:</span> {sale.numeroIdentite || 'Non spécifié'}</div>
<div><span className="font-medium">Autorité de délivrance:</span> {sale.autoriteDelivrance || 'Non spécifiée'}</div>
<div>
<span className="font-medium">Date de délivrance:</span>{' '}
+5 -1
View File
@@ -19,8 +19,12 @@ export function validateRequiredFields(formData: any): string[] {
{ key: 'typeArticle', label: 'Type d\'article' },
{ key: 'categorie', label: 'Catégorie' },
{ key: 'quantite', label: 'Quantité' },
{ key: 'gencode', label: 'Gencode' },
{ key: 'nom', label: 'Nom' },
{ key: 'prenom', label: 'Prénom' }
{ key: 'prenom', label: 'Prénom' },
{ key: 'dateNaissance', label: 'Date de naissance' },
{ key: 'typeIdentite', label: 'Type de pièce d\'identité' },
{ key: 'numeroIdentite', label: 'Numéro de pièce d\'identité' }
];
return requiredFields
+5 -3
View File
@@ -10,16 +10,17 @@ export interface Sale {
typeArticle: string;
categorie: 'F2' | 'F3';
quantite: number;
gencode?: string;
gencode: string;
// Client
nom: string;
prenom: string;
dateNaissance?: string;
dateNaissance: string;
lieuNaissance?: string;
// Identité
typeIdentite?: string;
typeIdentite: string;
numeroIdentite: string;
autoriteDelivrance?: string;
dateDelivrance?: string;
@@ -40,6 +41,7 @@ export interface FormData {
dateNaissance: string;
lieuNaissance: string;
typeIdentite: string;
numeroIdentite: string;
autoriteDelivrance: string;
dateDelivrance: string;
photoRecto?: string;