From 0f431676f53303c6e8e86a926beb9acad7cab9f7 Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Tue, 9 Sep 2025 13:22:40 +0000 Subject: [PATCH 1/5] Add ability to add comments to delivery verification records Adds functionality to comment on delivery verification items, including a modal for text input and state management for comments. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869/yiEpJFx --- client/src/pages/BLReconciliation.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/src/pages/BLReconciliation.tsx b/client/src/pages/BLReconciliation.tsx index f5b1570..b7e4b4a 100644 --- a/client/src/pages/BLReconciliation.tsx +++ b/client/src/pages/BLReconciliation.tsx @@ -12,7 +12,7 @@ import { useStore } from "@/components/Layout"; import { useAuthUnified } from "@/hooks/useAuthUnified"; import { usePermissions } from "@shared/permissions"; import { Pagination, usePagination } from "@/components/ui/pagination"; -import { Search, Edit, FileText, Settings, Eye, AlertTriangle, X, Check, Trash2, Ban, Filter, Upload, CheckCircle, XCircle, Clock } from "lucide-react"; +import { Search, Edit, FileText, Settings, Eye, AlertTriangle, X, Check, Trash2, Ban, Filter, Upload, CheckCircle, XCircle, Clock, MessageSquare } from "lucide-react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Label } from "@/components/ui/label"; @@ -66,6 +66,11 @@ export default function BLReconciliation() { const [verificationResults, setVerificationResults] = useState>({}); const [verifyingDeliveries, setVerifyingDeliveries] = useState>(new Set()); + // État pour le modal de commentaire + const [showCommentModal, setShowCommentModal] = useState(false); + const [selectedDeliveryForComment, setSelectedDeliveryForComment] = useState(null); + const [commentText, setCommentText] = useState(""); + // Récupérer les fournisseurs pour la logique automatique const { data: suppliers = [] } = useQuery({ queryKey: ['/api/suppliers'], From 9e5855d496c83a5da20975efe2b94ff5eb8d7667 Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Tue, 9 Sep 2025 13:24:19 +0000 Subject: [PATCH 2/5] Add ability for users to add and edit notes for delivery items Integrates a new feature allowing users to add, view, and edit notes for delivery items. This includes a mutation for updating notes via `PUT /api/deliveries/:deliveryId/notes`, associated modal components for user interaction, and toast notifications for success/error feedback. The `BLReconciliation` page is updated to include a button to trigger the comment modal and `queryClient.invalidateQueries` calls to refresh data upon successful note updates. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869/yiEpJFx --- client/src/pages/BLReconciliation.tsx | 69 +++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/client/src/pages/BLReconciliation.tsx b/client/src/pages/BLReconciliation.tsx index b7e4b4a..9360f26 100644 --- a/client/src/pages/BLReconciliation.tsx +++ b/client/src/pages/BLReconciliation.tsx @@ -142,6 +142,42 @@ export default function BLReconciliation() { } }); + // Mutation pour mettre à jour les notes + const updateNoteMutation = useMutation({ + mutationFn: async ({ deliveryId, notes }: { deliveryId: number; notes: string }) => { + const response = await apiRequest(`/api/deliveries/${deliveryId}/notes`, 'PUT', { notes }); + return response; + }, + onSuccess: () => { + toast({ + title: "Commentaire sauvegardé", + description: "Le commentaire a été mis à jour avec succès", + }); + // Rafraîchir les données + queryClient.invalidateQueries({ queryKey: ['/api/deliveries/bl'] }); + queryClient.invalidateQueries({ queryKey: ['/api/deliveries'] }); + handleCloseCommentModal(); + }, + onError: (error) => { + console.error('Erreur sauvegarde commentaire:', error); + toast({ + title: "Erreur", + description: "Impossible de sauvegarder le commentaire", + variant: "destructive", + }); + } + }); + + // Fonction pour sauvegarder le commentaire + const handleSaveComment = () => { + if (!selectedDeliveryForComment) return; + + updateNoteMutation.mutate({ + deliveryId: selectedDeliveryForComment.id, + notes: commentText + }); + }; + // Fonction pour déclencher la vérification const handleVerifyInvoice = (delivery: any, forceRefresh: boolean = false) => { // Accepter soit une référence de facture soit un numéro BL @@ -352,6 +388,19 @@ export default function BLReconciliation() { setShowInvoiceModal(true); }; + // Fonctions pour le modal de commentaire + const handleOpenCommentModal = (delivery: any) => { + setSelectedDeliveryForComment(delivery); + setCommentText(delivery.notes || ""); + setShowCommentModal(true); + }; + + const handleCloseCommentModal = () => { + setShowCommentModal(false); + setSelectedDeliveryForComment(null); + setCommentText(""); + }; + const handleCloseInvoiceModal = () => { setShowInvoiceModal(false); setSelectedDeliveryForInvoice(null); @@ -931,6 +980,15 @@ export default function BLReconciliation() { )} + {!delivery.reconciled ? ( <> {permissions.canValidate('reconciliation') && ( @@ -1134,6 +1192,17 @@ export default function BLReconciliation() { )} + {(permissions.canEdit('reconciliation') || permissions.canValidate('reconciliation')) && (