diff --git a/components/carnet/contact-details.tsx b/components/carnet/contact-details.tsx index f7b2dc5c..720ecce6 100644 --- a/components/carnet/contact-details.tsx +++ b/components/carnet/contact-details.tsx @@ -14,6 +14,8 @@ interface Contact { group?: string; } +type ContactField = 'email' | 'phone' | 'organization' | 'address'; + interface ContactDetailsProps { contact: Contact | null; onSave?: (contact: Contact) => void; @@ -51,7 +53,7 @@ export const ContactDetails: React.FC = ({ contact, onSave, setIsEditing(false); }; - const renderField = (label: string, value: string | undefined, field: keyof Contact, icon: React.ReactNode) => { + const renderField = (label: string, value: string | undefined, field: ContactField, icon: React.ReactNode) => { const bgColor = { email: 'bg-blue-50', phone: 'bg-green-50', @@ -106,7 +108,7 @@ export const ContactDetails: React.FC = ({ contact, onSave, /> ) : (

- {contact.fullName || contact.email || 'Sans nom'} + {contact?.fullName || contact?.email || 'Sans nom'}

)} @@ -153,10 +155,10 @@ export const ContactDetails: React.FC = ({ contact, onSave,
- {renderField('Email', contact.email, 'email', )} - {renderField('Téléphone', contact.phone, 'phone', )} - {renderField('Organisation', contact.organization, 'organization', )} - {renderField('Adresse', contact.address, 'address', )} + {renderField('Email', contact?.email, 'email', )} + {renderField('Téléphone', contact?.phone, 'phone', )} + {renderField('Organisation', contact?.organization, 'organization', )} + {renderField('Adresse', contact?.address, 'address', )}
@@ -169,7 +171,7 @@ export const ContactDetails: React.FC = ({ contact, onSave, placeholder="Ajouter des notes..." /> ) : ( -

{contact.notes}

+

{contact?.notes}

)}