import React, { useEffect, useState } from 'react' import { IoCheckmark } from 'react-icons/io5'; import { MdKeyboardArrowDown } from 'react-icons/md'; import { useSelector } from 'react-redux'; import { RootState } from '../../../../store/store'; interface SelectedRecipientsIntr { id: number; firstName: string; lastName: string; color: string; } interface RecipientsAttrConIntr { selectedRecipientId: number; handlePropertyChange: (changeTo: string, changeWith: string | boolean | number) => void; } const RecipientsAttrCon: React.FC = ({ selectedRecipientId, handlePropertyChange }) => { const [selectedRecipient, setSelectedRecipient] = useState(null); const selectedRecipients = useSelector((state: RootState) => state.selectedRecipients.recipients); const [dropDownToggle, setDropDownToggle] = useState(false); useEffect(() => { if (selectedRecipients.length) { const filter = selectedRecipients.filter((obj, indx) => obj.id == selectedRecipientId) setSelectedRecipient(filter[0]); } }, [selectedRecipientId]) if (!selectedRecipient) { return ( <> ) } return ( <>
setDropDownToggle(false)}> {/* Selected Recipient */}
setDropDownToggle(!dropDownToggle)} className='flex items-center justify-between gap-2 w-full p-2 text-xs rounded-sm border-1 border-slate-200 cursor-pointer'>

{/* */}

{"firstName" in selectedRecipient && selectedRecipient.firstName} {"lastName" in selectedRecipient && selectedRecipient.lastName}

{selectedRecipients.length && selectedRecipients.map((recipient, indx) => { return (
{ handlePropertyChange('recipientId', recipient.id); setTimeout(() => { setDropDownToggle(false); }, 0) }} >

{/* */}

{recipient.firstName} {recipient.lastName}

{selectedRecipientId === recipient.id && }
) })}
) } export default RecipientsAttrCon