import React, { useEffect } from "react"; import Avatar from "../common/Avatar"; import { getEmailIcon, getPhoneIcon } from "./DirectoryUtils"; import { useDir } from "../../Context/DireContext"; const ListViewDirectory = ({ IsActive, contact, setSelectedContact, setIsOpenModal, setOpen_contact, setIsOpenModalNote, IsDeleted, restore, }) => { const { dirActions, setDirActions } = useDir(); // Get the first email and phone number if they exist const firstEmail = contact.contactEmails?.[0]; const firstPhone = contact.contactPhones?.[0]; return ( { if (IsActive) { setIsOpenModalNote(true); setOpen_contact(contact); } }} >
{contact?.name || ""}
{firstEmail ? ( {firstEmail.emailAddress} ) : ( NA )}
{firstPhone ? ( {firstPhone.phoneNumber} ) : ( NA )}
{contact.organization} {contact?.contactCategory?.name || "Other"} {IsActive && ( <> { setSelectedContact(contact); setIsOpenModal(true); }} > IsDeleted(contact.id)} > )} {!IsActive && ( { setDirActions({ action: false, id: contact.id }); restore(contact.id); }} > )} ); }; export default ListViewDirectory;