From add7e45af9c864c647bf18f8b9b4eb15f704f114 Mon Sep 17 00:00:00 2001 From: alma Date: Sun, 20 Apr 2025 21:58:28 +0200 Subject: [PATCH] carnet panel contact --- app/carnet/page.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/carnet/page.tsx b/app/carnet/page.tsx index b5c97f2a..4b8e1edf 100644 --- a/app/carnet/page.tsx +++ b/app/carnet/page.tsx @@ -164,7 +164,9 @@ export default function CarnetPage() { const parseVCard = (content: string): Contact[] => { try { + // Split the content into individual vCards const vcards = content.split('BEGIN:VCARD').filter(section => section.trim()); + return vcards.map(section => { const vcard = new VCard(); vcard.parse('BEGIN:VCARD' + section); @@ -179,7 +181,8 @@ export default function CarnetPage() { const notes = vcard.getProperty('NOTE')?.value; const group = vcard.getProperty('CATEGORIES')?.value; - return { + // Create a clean contact object + const contact: Contact = { id: uid || Math.random().toString(36).substr(2, 9), fullName: fullName || 'Unknown Contact', email: email || '', @@ -189,6 +192,8 @@ export default function CarnetPage() { notes: notes || '', group: group || '' }; + + return contact; }); } catch (error) { console.error('Error parsing VCF content:', error); @@ -199,6 +204,7 @@ export default function CarnetPage() { const fetchContacts = async (folder: string) => { try { setIsLoadingContacts(true); + // First, check if we're looking at a specific VCF file if (folder.endsWith('.vcf')) { const response = await fetch(`/api/nextcloud/files/content?path=${encodeURIComponent(`/files/cube-${session?.user?.id}/Private/Contacts/${folder}`)}`);