From a8e040f097c6b3307df15a9eab821069b192fd67 Mon Sep 17 00:00:00 2001 From: alma Date: Sun, 20 Apr 2025 20:11:44 +0200 Subject: [PATCH] carnet panel contact --- app/carnet/page.tsx | 41 +++++----- components/carnet/contact-details.tsx | 112 ++++++++++++++++++++++++++ components/carnet/contacts-view.tsx | 50 ------------ 3 files changed, 135 insertions(+), 68 deletions(-) create mode 100644 components/carnet/contact-details.tsx diff --git a/app/carnet/page.tsx b/app/carnet/page.tsx index 54c7997d..23f080e9 100644 --- a/app/carnet/page.tsx +++ b/app/carnet/page.tsx @@ -10,6 +10,7 @@ import { PanelResizer } from "@/components/carnet/panel-resizer"; import { useMediaQuery } from "@/hooks/use-media-query"; import { ContactsView } from '@/components/carnet/contacts-view'; import { X, Menu } from "lucide-react"; +import { ContactDetails } from '@/components/carnet/contact-details'; // Layout modes export enum PaneLayout { @@ -495,24 +496,28 @@ export default function CarnetPage() { {/* Editor Panel */}
- { - // Refresh the notes list - fetch(`/api/nextcloud/files?folder=${selectedFolder}`) - .then(response => response.json()) - .then(updatedNotes => { - if (selectedFolder === 'Contacts') { - setContacts(updatedNotes); - } else { - setNotes(updatedNotes); - } - }) - .catch(error => console.error('Error refreshing data:', error)); - }} - /> + {selectedFolder === 'Contacts' || selectedFolder.endsWith('.vcf') ? ( + + ) : ( + { + // Refresh the notes list + fetch(`/api/nextcloud/files?folder=${selectedFolder}`) + .then(response => response.json()) + .then(updatedNotes => { + if (selectedFolder === 'Contacts') { + setContacts(updatedNotes); + } else { + setNotes(updatedNotes); + } + }) + .catch(error => console.error('Error refreshing data:', error)); + }} + /> + )}
{/* Mobile Navigation Toggle */} diff --git a/components/carnet/contact-details.tsx b/components/carnet/contact-details.tsx new file mode 100644 index 00000000..2ea250bf --- /dev/null +++ b/components/carnet/contact-details.tsx @@ -0,0 +1,112 @@ +"use client"; + +import React from 'react'; +import { User, Mail, Phone, Building, MapPin } from 'lucide-react'; + +interface Contact { + id: string; + fullName?: string; + email?: string; + phone?: string; + organization?: string; + address?: string; + notes?: string; + group?: string; +} + +interface ContactDetailsProps { + contact: Contact | null; +} + +export const ContactDetails: React.FC = ({ contact }) => { + if (!contact) { + return ( +
+ +

Sélectionnez un contact pour voir les détails

+
+ ); + } + + return ( +
+
+ {/* Contact Header */} +
+
+ +
+
+

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

+ {contact.organization && ( +

+ {contact.organization} +

+ )} +
+
+ + {/* Contact Information */} +
+ {contact.email && ( +
+
+ +
+
+

Email

+

{contact.email}

+
+
+ )} + + {contact.phone && ( +
+
+ +
+
+

Téléphone

+

{contact.phone}

+
+
+ )} + + {contact.organization && ( +
+
+ +
+
+

Organisation

+

{contact.organization}

+
+
+ )} + + {contact.address && ( +
+
+ +
+
+

Adresse

+

{contact.address}

+
+
+ )} +
+ + {/* Notes Section */} + {contact.notes && ( +
+

Notes

+

{contact.notes}

+
+ )} +
+
+ ); +}; \ No newline at end of file diff --git a/components/carnet/contacts-view.tsx b/components/carnet/contacts-view.tsx index 9cff5c76..d1ef2c9e 100644 --- a/components/carnet/contacts-view.tsx +++ b/components/carnet/contacts-view.tsx @@ -91,56 +91,6 @@ export const ContactsView: React.FC = ({ )} - - {/* Contact Details */} - {selectedContact && ( -
-
-
-
- -
-
-

- {selectedContact.fullName} -

- {selectedContact.organization && ( -

- {selectedContact.organization} -

- )} -
-
- -
- {selectedContact.email && ( -
- - {selectedContact.email} -
- )} - {selectedContact.phone && ( -
- - {selectedContact.phone} -
- )} - {selectedContact.address && ( -
- - {selectedContact.address} -
- )} - {selectedContact.notes && ( -
-

Notes

-

{selectedContact.notes}

-
- )} -
-
-
- )} ); }; \ No newline at end of file