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] 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 - - + +
- - -
- -
- +