From dd0a8ca702fd56aad35cb48fa5129a57fbab60b9 Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Wed, 10 Sep 2025 08:02:06 +0000 Subject: [PATCH 1/3] Add reconciliation comments for improved task tracking Update the BL reconciliation page to use a new endpoint for creating reconciliation comments, replacing the previous note functionality. This change involves updating the mutation, success and error handlers, and button disabled states to reflect the new comment creation process. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 95e8aab4-f39f-4b48-aa57-a759ec15ba3d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/95e8aab4-f39f-4b48-aa57-a759ec15ba3d/BOWXK9F --- client/src/pages/BLReconciliation.tsx | 31 +++++++++++++++------------ 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/client/src/pages/BLReconciliation.tsx b/client/src/pages/BLReconciliation.tsx index 05dcbe3..bc82ee8 100644 --- a/client/src/pages/BLReconciliation.tsx +++ b/client/src/pages/BLReconciliation.tsx @@ -143,16 +143,19 @@ 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 }); + // Mutation pour créer un nouveau commentaire de rapprochement + const createCommentMutation = useMutation({ + mutationFn: async ({ deliveryId, content }: { deliveryId: number; content: string }) => { + const response = await apiRequest(`/api/deliveries/${deliveryId}/reconciliation-comments`, 'POST', { + content, + type: 'info' + }); return response; }, onSuccess: () => { toast({ - title: "Commentaire sauvegardé", - description: "Le commentaire a été mis à jour avec succès", + title: "Commentaire ajouté", + description: "Le commentaire a été ajouté avec succès", }); // Rafraîchir les données queryClient.invalidateQueries({ queryKey: ['/api/deliveries/bl'] }); @@ -160,10 +163,10 @@ export default function BLReconciliation() { handleCloseCommentModal(); }, onError: (error) => { - console.error('Erreur sauvegarde commentaire:', error); + console.error('Erreur ajout commentaire:', error); toast({ title: "Erreur", - description: "Impossible de sauvegarder le commentaire", + description: "Impossible d'ajouter le commentaire", variant: "destructive", }); } @@ -171,11 +174,11 @@ export default function BLReconciliation() { // Fonction pour sauvegarder le commentaire const handleSaveComment = () => { - if (!selectedDeliveryForComment) return; + if (!selectedDeliveryForComment || !commentText.trim()) return; - updateNoteMutation.mutate({ + createCommentMutation.mutate({ deliveryId: selectedDeliveryForComment.id, - notes: commentText + content: commentText }); }; @@ -1440,16 +1443,16 @@ export default function BLReconciliation() { {!selectedDeliveryForComment?.reconciled && ( )} From edbf082c8d9b91987eded4db38a0e44ab18ff3fd Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Wed, 10 Sep 2025 09:26:57 +0000 Subject: [PATCH 2/3] Remove informational comment types from the reconciliation system Remove the 'info' comment type and its associated UI elements, icons, and default values across the client and shared schema. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 95e8aab4-f39f-4b48-aa57-a759ec15ba3d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/95e8aab4-f39f-4b48-aa57-a759ec15ba3d/i5ZCBt1 --- .../src/components/ReconciliationComments.tsx | 25 ++++++++----------- client/src/pages/BLReconciliation.tsx | 2 +- shared/schema.ts | 2 +- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/client/src/components/ReconciliationComments.tsx b/client/src/components/ReconciliationComments.tsx index 9ed7b66..78d2c92 100644 --- a/client/src/components/ReconciliationComments.tsx +++ b/client/src/components/ReconciliationComments.tsx @@ -10,7 +10,7 @@ import { Textarea } from "@/components/ui/textarea"; import { useToast } from "@/hooks/use-toast"; import { apiRequest } from "@/lib/queryClient"; import { safeFormat } from "@/lib/dateUtils"; -import { MessageSquare, Plus, Edit2, Trash2, Save, X, AlertCircle, Info, CheckCircle, AlertTriangle } from "lucide-react"; +import { MessageSquare, Plus, Edit2, Trash2, Save, X, AlertCircle, CheckCircle, AlertTriangle } from "lucide-react"; interface ReconciliationCommentsProps { deliveryId: number; @@ -20,7 +20,7 @@ interface ReconciliationCommentsProps { interface ReconciliationComment { id: number; content: string; - type: 'info' | 'warning' | 'error' | 'success'; + type: 'warning' | 'error' | 'success'; deliveryId: number; authorId: string; groupId: number; @@ -34,21 +34,18 @@ interface ReconciliationComment { } const typeColors = { - info: "bg-blue-50 border-blue-200 text-blue-800", warning: "bg-yellow-50 border-yellow-200 text-yellow-800", error: "bg-red-50 border-red-200 text-red-800", success: "bg-green-50 border-green-200 text-green-800", }; const typeIcons = { - info: Info, warning: AlertTriangle, error: AlertCircle, success: CheckCircle, }; const typeLabels = { - info: "Information", warning: "Attention", error: "Erreur", success: "Succès", @@ -62,17 +59,17 @@ export default function ReconciliationComments({ deliveryId, className = "" }: R const [editingId, setEditingId] = useState(null); const [newComment, setNewComment] = useState<{ content: string; - type: 'info' | 'warning' | 'error' | 'success'; + type: 'warning' | 'error' | 'success'; }>({ content: "", - type: "info", + type: "warning", }); const [editComment, setEditComment] = useState<{ content: string; - type: 'info' | 'warning' | 'error' | 'success'; + type: 'warning' | 'error' | 'success'; }>({ content: "", - type: "info", + type: "warning", }); // Récupérer les commentaires @@ -94,7 +91,7 @@ export default function ReconciliationComments({ deliveryId, className = "" }: R }); queryClient.invalidateQueries({ queryKey: [`/api/deliveries/${deliveryId}/reconciliation-comments`] }); setIsAdding(false); - setNewComment({ content: "", type: "info" }); + setNewComment({ content: "", type: "warning" }); }, onError: (error: any) => { toast({ @@ -174,7 +171,7 @@ export default function ReconciliationComments({ deliveryId, className = "" }: R const handleCancelEdit = () => { setEditingId(null); - setEditComment({ content: "", type: "info" }); + setEditComment({ content: "", type: "warning" }); }; const handleDeleteComment = (id: number) => { @@ -235,7 +232,7 @@ export default function ReconciliationComments({ deliveryId, className = "" }: R - Information + Attention Erreur Succès @@ -261,7 +258,7 @@ export default function ReconciliationComments({ deliveryId, className = "" }: R size="sm" onClick={() => { setIsAdding(false); - setNewComment({ content: "", type: "info" }); + setNewComment({ content: "", type: "warning" }); }} > @@ -308,7 +305,7 @@ export default function ReconciliationComments({ deliveryId, className = "" }: R - Information + Attention Erreur Succès diff --git a/client/src/pages/BLReconciliation.tsx b/client/src/pages/BLReconciliation.tsx index bc82ee8..d23d765 100644 --- a/client/src/pages/BLReconciliation.tsx +++ b/client/src/pages/BLReconciliation.tsx @@ -148,7 +148,7 @@ export default function BLReconciliation() { mutationFn: async ({ deliveryId, content }: { deliveryId: number; content: string }) => { const response = await apiRequest(`/api/deliveries/${deliveryId}/reconciliation-comments`, 'POST', { content, - type: 'info' + type: 'warning' }); return response; }, diff --git a/shared/schema.ts b/shared/schema.ts index ce3fbdf..65ee1e1 100644 --- a/shared/schema.ts +++ b/shared/schema.ts @@ -183,7 +183,7 @@ export const reconciliationComments = pgTable("reconciliation_comments", { deliveryId: integer("delivery_id").notNull(), // Référence vers la livraison concernée groupId: integer("group_id").notNull(), // Magasin/groupe pour filtrage content: text("content").notNull(), // Contenu du commentaire - type: varchar("type", { length: 50 }).notNull().default("info"), // info, warning, error, success + type: varchar("type", { length: 50 }).notNull().default("warning"), // warning, error, success authorId: varchar("author_id").notNull(), // Utilisateur auteur du commentaire createdAt: timestamp("created_at").defaultNow(), updatedAt: timestamp("updated_at").defaultNow(), From deb01d1a8185b2f958e9ccedade21dfc21cdc58b Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Wed, 10 Sep 2025 09:31:05 +0000 Subject: [PATCH 3/3] Simplify comment system by removing type and message functionality Remove comment type, associated icons, labels, and related UI elements. Update API calls and database schema to reflect these changes, simplifying the comment submission and management process. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 95e8aab4-f39f-4b48-aa57-a759ec15ba3d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/95e8aab4-f39f-4b48-aa57-a759ec15ba3d/2QB13hj --- .../src/components/ReconciliationComments.tsx | 189 +++++------------- client/src/pages/BLReconciliation.tsx | 3 +- server/storage.ts | 1 - shared/schema.ts | 1 - 4 files changed, 54 insertions(+), 140 deletions(-) diff --git a/client/src/components/ReconciliationComments.tsx b/client/src/components/ReconciliationComments.tsx index 78d2c92..cff2ca2 100644 --- a/client/src/components/ReconciliationComments.tsx +++ b/client/src/components/ReconciliationComments.tsx @@ -1,16 +1,14 @@ import React, { useState } from "react"; import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Badge } from "@/components/ui/badge"; -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; +import { Card, CardContent } from "@/components/ui/card"; import { Textarea } from "@/components/ui/textarea"; import { useToast } from "@/hooks/use-toast"; import { apiRequest } from "@/lib/queryClient"; import { safeFormat } from "@/lib/dateUtils"; -import { MessageSquare, Plus, Edit2, Trash2, Save, X, AlertCircle, CheckCircle, AlertTriangle } from "lucide-react"; +import { MessageSquare, Plus, Edit2, Trash2, Save, X } from "lucide-react"; interface ReconciliationCommentsProps { deliveryId: number; @@ -20,7 +18,6 @@ interface ReconciliationCommentsProps { interface ReconciliationComment { id: number; content: string; - type: 'warning' | 'error' | 'success'; deliveryId: number; authorId: string; groupId: number; @@ -33,44 +30,14 @@ interface ReconciliationComment { }; } -const typeColors = { - warning: "bg-yellow-50 border-yellow-200 text-yellow-800", - error: "bg-red-50 border-red-200 text-red-800", - success: "bg-green-50 border-green-200 text-green-800", -}; - -const typeIcons = { - warning: AlertTriangle, - error: AlertCircle, - success: CheckCircle, -}; - -const typeLabels = { - warning: "Attention", - error: "Erreur", - success: "Succès", -}; - export default function ReconciliationComments({ deliveryId, className = "" }: ReconciliationCommentsProps) { const { toast } = useToast(); const queryClient = useQueryClient(); const [isAdding, setIsAdding] = useState(false); const [editingId, setEditingId] = useState(null); - const [newComment, setNewComment] = useState<{ - content: string; - type: 'warning' | 'error' | 'success'; - }>({ - content: "", - type: "warning", - }); - const [editComment, setEditComment] = useState<{ - content: string; - type: 'warning' | 'error' | 'success'; - }>({ - content: "", - type: "warning", - }); + const [newComment, setNewComment] = useState(""); + const [editComment, setEditComment] = useState(""); // Récupérer les commentaires const { data: comments = [], isLoading } = useQuery({ @@ -81,8 +48,8 @@ export default function ReconciliationComments({ deliveryId, className = "" }: R // Créer un commentaire const createCommentMutation = useMutation({ - mutationFn: async (data: { content: string; type: string }) => { - return apiRequest(`/api/deliveries/${deliveryId}/reconciliation-comments`, "POST", data); + mutationFn: async (content: string) => { + return apiRequest(`/api/deliveries/${deliveryId}/reconciliation-comments`, "POST", { content }); }, onSuccess: () => { toast({ @@ -91,7 +58,7 @@ export default function ReconciliationComments({ deliveryId, className = "" }: R }); queryClient.invalidateQueries({ queryKey: [`/api/deliveries/${deliveryId}/reconciliation-comments`] }); setIsAdding(false); - setNewComment({ content: "", type: "warning" }); + setNewComment(""); }, onError: (error: any) => { toast({ @@ -104,8 +71,8 @@ export default function ReconciliationComments({ deliveryId, className = "" }: R // Modifier un commentaire const updateCommentMutation = useMutation({ - mutationFn: async ({ id, data }: { id: number; data: { content: string; type: string } }) => { - return apiRequest(`/api/reconciliation-comments/${id}`, "PUT", data); + mutationFn: async ({ id, content }: { id: number; content: string }) => { + return apiRequest(`/api/reconciliation-comments/${id}`, "PUT", { content }); }, onSuccess: () => { toast({ @@ -147,31 +114,28 @@ export default function ReconciliationComments({ deliveryId, className = "" }: R const handleAddComment = (e: React.FormEvent) => { e.preventDefault(); - if (!newComment.content.trim()) return; + if (!newComment.trim()) return; createCommentMutation.mutate(newComment); }; const handleEditComment = (comment: ReconciliationComment) => { setEditingId(comment.id); - setEditComment({ - content: comment.content, - type: comment.type, - }); + setEditComment(comment.content); }; const handleSaveEdit = () => { - if (!editComment.content.trim() || !editingId) return; + if (!editComment.trim() || !editingId) return; updateCommentMutation.mutate({ id: editingId, - data: editComment, + content: editComment, }); }; const handleCancelEdit = () => { setEditingId(null); - setEditComment({ content: "", type: "warning" }); + setEditComment(""); }; const handleDeleteComment = (id: number) => { @@ -194,7 +158,7 @@ export default function ReconciliationComments({ deliveryId, className = "" }: R

- Commentaires de rapprochement + Commentaires {comments.length > 0 && ( {comments.length} @@ -202,52 +166,31 @@ export default function ReconciliationComments({ deliveryId, className = "" }: R )}

- {!isAdding && ( - - )} +
{/* Formulaire d'ajout */} {isAdding && ( - - - Nouveau commentaire - - + +
- - -
- -
- +