From 3ae1dc31fe4592b75c8372f6aa834bbb5210d96f Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Mon, 8 Sep 2025 15:25:34 +0000 Subject: [PATCH] Add edit and delete functionality for task management entries Update the Avoirs page to display entries in a table format, including edit and delete icons for administrative users. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869/5h3gCuD --- client/src/pages/Avoirs.tsx | 232 ++++++++++++++++++++---------------- 1 file changed, 126 insertions(+), 106 deletions(-) diff --git a/client/src/pages/Avoirs.tsx b/client/src/pages/Avoirs.tsx index 9cc3755..22e21e8 100644 --- a/client/src/pages/Avoirs.tsx +++ b/client/src/pages/Avoirs.tsx @@ -1,6 +1,6 @@ import { useState } from "react"; import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; -import { Plus, Search, FileText, CheckCircle, AlertCircle, Clock } from "lucide-react"; +import { Plus, Search, FileText, CheckCircle, AlertCircle, Clock, Edit, Trash2 } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; @@ -418,112 +418,132 @@ export default function Avoirs() { )} - {/* Avoirs List */} -
- {isLoading ? ( - Array.from({ length: 6 }).map((_, i) => ( - - -
-
-
- -
-
-
-
-
-
- )) - ) : filteredAvoirs.length === 0 ? ( -
- -

Aucun avoir

-

- Commencez par créer votre premier avoir. -

-
- ) : ( - filteredAvoirs.map((avoir) => ( - - -
- - {getStatusIcon(avoir.status)} - #{avoir.invoiceReference || 'Sans référence'} - - - {avoir.status} - -
- -
-
- {avoir.group.name} -
- - - -
-
- Fournisseur: - {avoir.supplier.name} -
+ {/* Avoirs List - Format Table */} +
+
+ {isLoading ? ( +
+
+ {Array.from({ length: 3 }).map((_, i) => ( +
+ ))} +
+
+ ) : filteredAvoirs.length === 0 ? ( +
+ +

Aucun avoir

+

+ {searchTerm ? "Aucun avoir ne correspond à votre recherche." : "Commencez par créer votre premier avoir."} +

+ {canCreate && !searchTerm && ( + + )} +
+ ) : ( + + + + + + + + + + + + + + {filteredAvoirs.map((avoir) => { + const canEditDelete = ['admin', 'directeur'].includes((user as any)?.role); -
- Montant: - {avoir.amount ? avoir.amount.toFixed(2) + ' €' : 'Non spécifié'} -
- - {avoir.comment && ( -
-

- "{avoir.comment}" -

-
- )} - -
-
- - Par {avoir.creator.firstName && avoir.creator.lastName - ? `${avoir.creator.firstName} ${avoir.creator.lastName}` - : avoir.creator.username - } - - - {format(new Date(avoir.createdAt), "dd/MM/yyyy", { locale: fr })} - -
-
- - {avoir.commercialProcessed && ( -
- - Traité par commercial -
- )} - -
- {avoir.webhookSent && ( - - Webhook envoyé - - )} - {avoir.nocodbVerified && ( - - Vérifié NocoDB - - )} -
- - - - )) - )} + return ( + + + + + + + + + + ); + })} + +
+ Statut + + Référence + + Fournisseur + + Magasin + + Montant + + Créé le + + Actions +
+
+ {getStatusIcon(avoir.status)} + + {avoir.status} + +
+
+ #{avoir.invoiceReference || 'Sans référence'} + + {avoir.supplier.name} + +
+
+ {avoir.group.name} +
+
+ {avoir.amount ? `${avoir.amount.toFixed(2)} €` : 'Non spécifié'} + +
+
{format(new Date(avoir.createdAt), "dd/MM/yyyy", { locale: fr })}
+
+ Par {avoir.creator.firstName && avoir.creator.lastName + ? `${avoir.creator.firstName} ${avoir.creator.lastName}` + : avoir.creator.username + } +
+
+
+ {canEditDelete ? ( +
+ + +
+ ) : ( + Lecture seule + )} +
+ )} +
);