carnet panel contact
This commit is contained in:
parent
6beb394a84
commit
a10660a27f
@ -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', {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user