carnet panel contact

This commit is contained in:
alma 2025-04-20 22:17:07 +02:00
parent 6beb394a84
commit a10660a27f

View File

@ -454,13 +454,16 @@ export default function CarnetPage() {
}
const { content } = await response.json();
const contacts = parseVCardContent(content);
// Remove the contact
const updatedContacts = contacts.filter(c => c.id !== contact.id);
// Split the content into individual vCards and filter out the one to delete
const vcards = content.split('BEGIN:VCARD').filter(section => section.trim());
const updatedVcards = vcards.filter(section => {
const vcard = parseVCard('BEGIN:VCARD' + section);
return vcard.uid?.[0]?.value !== contact.id;
});
// Generate new VCF content
const vcfContent = updatedContacts.map(c => generateVCardContent(c)).join('\n');
// Join the remaining vCards back together
const vcfContent = updatedVcards.map(section => 'BEGIN:VCARD' + section).join('\n');
// Save the updated VCF file
const saveResponse = await fetch('/api/nextcloud/files', {