import React from "react";
import { Plus, User, Mail, Phone, Building2, Edit, Trash2 } from "lucide-react";
import PrimaryButton_v2 from "@/components/PrimaryButton_v2";
import { Contacts } from "@/types/clientType";
// ============================================
// TYPES
// ============================================
interface ClientContactsListProps {
contacts: Contacts[];
onCreateContact: () => void;
onEditContact: (contact: Contacts) => void;
onDeleteContact?: (contactId: string | number) => void;
showDeleteButton?: boolean;
}
// ============================================
// SOUS-COMPOSANTS
// ============================================
const EmptyState: React.FC = () => (
Aucun contact enregistré
Cliquez sur "Ajouter un contact" pour commencer
);
const ContactAvatar: React.FC<{ nom: string; prenom: string }> = ({ nom, prenom }) => (
{prenom?.[0] || ""}{nom?.[0] || ""}
);
const DefaultBadge: React.FC = () => (
Défaut
);
interface ContactInfoRowProps {
icon: React.ElementType;
value: string;
href?: string;
type?: "email" | "tel";
}
const ContactInfoRow: React.FC = ({ icon: Icon, value, href, type }) => {
const content = (
<>
{value}
>
);
if (href) {
return (
{content}
);
}
return (
{content}
);
};
interface ContactCardProps {
contact: Contacts;
onEdit: (contact: Contacts) => void;
onDelete?: (contactId: string | number) => void;
showDeleteButton?: boolean;
}
const ContactCard: React.FC = ({
contact,
onEdit,
onDelete,
showDeleteButton = false,
}) => (
{/* Header */}
{contact.prenom} {contact.nom}
{contact.fonction || "Pas de poste défini"}
{contact.est_defaut &&
}
{/* Contact Info */}
{contact.email && (
)}
{contact.telephone && (
)}
{/* Actions */}
{showDeleteButton && onDelete && contact.numero && (
)}
);
// ============================================
// COMPOSANT PRINCIPAL
// ============================================
const ClientContactsList: React.FC = ({
contacts,
onCreateContact,
onEditContact,
onDeleteContact,
showDeleteButton = false,
}) => {
const contactCount = contacts?.length || 0;
return (
{/* Header */}
Liste des contacts ({contactCount})
Ajouter un contact
{/* Content */}
{contactCount === 0 ? (
) : (
{contacts?.map((contact, index) => (
))}
)}
);
};
export default ClientContactsList;
// Export des sous-composants si besoin
export {
EmptyState,
ContactAvatar,
DefaultBadge,
ContactInfoRow,
ContactCard,
};