carnet panel contact
This commit is contained in:
parent
ef6f08b6bc
commit
6cef226948
@ -169,15 +169,25 @@ export default function CarnetPage() {
|
||||
const vcard = new VCard();
|
||||
vcard.parse('BEGIN:VCARD' + section);
|
||||
|
||||
// Extract contact properties with proper type handling
|
||||
const uid = vcard.getProperty('UID')?.value;
|
||||
const fullName = vcard.getProperty('FN')?.value;
|
||||
const email = vcard.getProperty('EMAIL')?.value;
|
||||
const phone = vcard.getProperty('TEL')?.value;
|
||||
const organization = vcard.getProperty('ORG')?.value;
|
||||
const address = vcard.getProperty('ADR')?.value;
|
||||
const notes = vcard.getProperty('NOTE')?.value;
|
||||
const group = vcard.getProperty('CATEGORIES')?.value;
|
||||
|
||||
return {
|
||||
id: vcard.getProperty('UID')?.value || Math.random().toString(36).substr(2, 9),
|
||||
fullName: vcard.getProperty('FN')?.value || '',
|
||||
email: vcard.getProperty('EMAIL')?.value || '',
|
||||
phone: vcard.getProperty('TEL')?.value || '',
|
||||
organization: vcard.getProperty('ORG')?.value || '',
|
||||
address: vcard.getProperty('ADR')?.value || '',
|
||||
notes: vcard.getProperty('NOTE')?.value || '',
|
||||
group: vcard.getProperty('CATEGORIES')?.value || ''
|
||||
id: uid || Math.random().toString(36).substr(2, 9),
|
||||
fullName: fullName || 'Unknown Contact',
|
||||
email: email || '',
|
||||
phone: phone || '',
|
||||
organization: organization || '',
|
||||
address: address || '',
|
||||
notes: notes || '',
|
||||
group: group || ''
|
||||
};
|
||||
});
|
||||
} catch (error) {
|
||||
@ -479,8 +489,11 @@ export default function CarnetPage() {
|
||||
const generateVCard = (contact: Contact): string => {
|
||||
const vcard = new VCard();
|
||||
|
||||
vcard.setProperty('UID', contact.id);
|
||||
vcard.setProperty('FN', contact.fullName);
|
||||
// Ensure required fields are not undefined
|
||||
vcard.setProperty('UID', contact.id || Math.random().toString(36).substr(2, 9));
|
||||
vcard.setProperty('FN', contact.fullName || 'Unknown Contact');
|
||||
|
||||
// Add optional fields only if they have values
|
||||
if (contact.email) vcard.setProperty('EMAIL', contact.email);
|
||||
if (contact.phone) vcard.setProperty('TEL', contact.phone);
|
||||
if (contact.organization) vcard.setProperty('ORG', contact.organization);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user