Make delivery validation require a mandatory delivery note number

Enforce the requirement for a delivery note number (blNumber) during delivery validation on both the delivery and calendar modules. This change updates the frontend validation schema to make blNumber a required field with a minimum length, modifies the backend logic to reject validations without a blNumber, and integrates a new modal component for handling this validation process within the Deliveries page.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 98f01874-e00c-4bbe-9d71-b0b338001848
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/98f01874-e00c-4bbe-9d71-b0b338001848/yaZkPAT
This commit is contained in:
michaelschal committed 2025-09-01 11:57:55 +00:00
1 parent 6dca340c45
commit c09388c0aa
3 files changed
+34 -60

No files matched your search

@@ -13,7 +13,7 @@ import { isUnauthorizedError } from "@/lib/authUtils";
import { Check, X } from "lucide-react";
const validateDeliverySchema = z.object({
blNumber: z.string().optional(),
blNumber: z.string().min(1, "Le numéro de bon de livraison est obligatoire"),
blAmount: z.string().optional(),
});
@@ -47,10 +47,8 @@ export default function ValidateDeliveryModal({
mutationFn: async (data: ValidateDeliveryForm) => {
const payload: any = {};
// Ajouter blNumber seulement s'il est fourni
if (data.blNumber && data.blNumber.trim() !== '') {
payload.blNumber = data.blNumber.trim();
}
// Le blNumber est maintenant obligatoire
payload.blNumber = data.blNumber.trim();
if (data.blAmount && data.blAmount.trim() !== '') {
payload.blAmount = parseFloat(data.blAmount);
@@ -137,10 +135,10 @@ export default function ValidateDeliveryModal({
name="blNumber"
render={({ field }) => (
<FormItem>
<FormLabel>N° Bon de Livraison</FormLabel>
<FormLabel>N° Bon de Livraison *</FormLabel>
<FormControl>
<Input
placeholder="Ex: BL-2024-001 (optionnel)"
placeholder="Ex: BL-2024-001"
{...field}
/>
</FormControl>