import React, { useEffect, useState } from "react"; import { useContactProfile } from "../../hooks/useDirectory"; import Avatar from "../common/Avatar"; import moment from "moment"; import NotesDirectory from "./NotesDirectory"; const ProfileContactDirectory = ({ contact, setOpen_contact, closeModal }) => { const { contactProfile, loading, refetch } = useContactProfile(contact?.id); const [copiedIndex, setCopiedIndex] = useState(null); const [profileContact, setProfileContact] = useState(); const [expanded, setExpanded] = useState(false); const description = contactProfile?.description || ""; const limit = 500; const toggleReadMore = () => setExpanded(!expanded); const isLong = description.length > limit; const displayText = expanded ? description : description.slice(0, limit) + (isLong ? "..." : ""); useEffect(() => { setProfileContact(contactProfile); }, [contactProfile]); const handleCopy = (email, index) => { navigator.clipboard.writeText(email); setCopiedIndex(index); setTimeout(() => setCopiedIndex(null), 2000); // Reset after 2 seconds }; return (

Contact Profile

{contact?.name} {contactProfile?.tags?.map((tag) => tag.name).join(" | ")}
{contactProfile?.contactEmails?.length > 0 && (

Email:

    {contactProfile.contactEmails.map((email, idx) => (
  • {email.emailAddress} handleCopy(email.emailAddress, idx)} >
  • ))}
)} {contactProfile?.contactPhones?.length > 0 && (

Phone :

    {contactProfile?.contactPhones.map((phone, idx) => (
  • {phone.phoneNumber}
  • ))}
)} {contactProfile?.createdAt && (

Created :

  • {moment(contactProfile.createdAt).format("MMMM, DD YYYY")}
  • )} {contactProfile?.address && (

    Location:

    {contactProfile.address}
    )}
    {contactProfile?.organization && (

    Orgnization :

    {contactProfile.organization}
    )} {contactProfile?.contactCategory && (

    Category :

    • {contactProfile.contactCategory.name}
    )} {contactProfile?.tags?.length > 0 && (

    Tags :

      {contactProfile.tags.map((tag, index) => (
    • {tag.name}
    • ))}
    )} {contactProfile?.buckets?.length > 0 && (
    {contactProfile?.contactEmails?.length > 0 && (

    Buckets :

      {contactProfile.buckets.map((bucket) => (
    • {bucket.name}
    • ))}
    )}
    )}
    {contactProfile?.projects?.length > 0 && (

    Projects :

      {contactProfile.projects.map((project, index) => (
    • {project.name} {index < contactProfile.projects.length - 1 && ","}
    • ))}
    )}

    Description :

    {displayText} {isLong && ( {expanded ? "Read less" : "Read more"} )}

    ); }; export default ProfileContactDirectory;