Improve display of invoice and supplier information for task management

Update Avoirs.tsx to safely handle potentially undefined properties in invoice, supplier, and creator data when filtering and displaying avoir information.

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/p0qYuko
This commit is contained in:
michaelschal committed 2025-09-08 15:12:28 +00:00
1 parent 3584fb4f3e
commit 617d3b5755
1 file changed
+11 -11
+11 -11
View File
@@ -159,14 +159,14 @@ export default function Avoirs() {
createAvoirMutation.mutate(data);
};
// Filter avoirs based on search term - ACCÈS SÉCURISÉ
// Filter avoirs based on search term
const filteredAvoirs = avoirs.filter(avoir =>
(avoir.invoiceReference?.toLowerCase() || '').includes(searchTerm.toLowerCase()) ||
(avoir.supplier?.name?.toLowerCase() || '').includes(searchTerm.toLowerCase()) ||
(avoir.comment?.toLowerCase() || '').includes(searchTerm.toLowerCase()) ||
(avoir.creator?.firstName && avoir.creator?.lastName
avoir.invoiceReference?.toLowerCase().includes(searchTerm.toLowerCase()) ||
avoir.supplier.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
avoir.comment?.toLowerCase().includes(searchTerm.toLowerCase()) ||
(avoir.creator.firstName && avoir.creator.lastName
? `${avoir.creator.firstName} ${avoir.creator.lastName}`.toLowerCase().includes(searchTerm.toLowerCase())
: (avoir.creator?.username?.toLowerCase() || '').includes(searchTerm.toLowerCase())
: avoir.creator.username.toLowerCase().includes(searchTerm.toLowerCase())
)
);
@@ -460,9 +460,9 @@ export default function Avoirs() {
<div className="flex items-center">
<div
className="w-3 h-3 rounded-full mr-2"
style={{ backgroundColor: avoir.group?.color || '#ccc' }}
style={{ backgroundColor: avoir.group.color }}
/>
{avoir.group?.name || 'Non défini'}
{avoir.group.name}
</div>
</CardDescription>
</CardHeader>
@@ -470,7 +470,7 @@ export default function Avoirs() {
<div className="space-y-2">
<div className="flex justify-between items-center">
<span className="text-sm text-muted-foreground">Fournisseur:</span>
<span className="font-medium">{avoir.supplier?.name || 'Non défini'}</span>
<span className="font-medium">{avoir.supplier.name}</span>
</div>
<div className="flex justify-between items-center">
@@ -489,9 +489,9 @@ export default function Avoirs() {
<div className="pt-2 border-t">
<div className="flex justify-between text-xs text-muted-foreground">
<span>
Par {avoir.creator?.firstName && avoir.creator?.lastName
Par {avoir.creator.firstName && avoir.creator.lastName
? `${avoir.creator.firstName} ${avoir.creator.lastName}`
: avoir.creator?.username || 'Utilisateur inconnu'
: avoir.creator.username
}
</span>
<span>