diff --git a/client/src/components/ContactsListField.js b/client/src/components/ContactsListField.js index 8db5fa0de..39a07d739 100644 --- a/client/src/components/ContactsListField.js +++ b/client/src/components/ContactsListField.js @@ -1,43 +1,51 @@ -import React, { useCallback, useState } from 'react'; -import { - MenuItem, - Button, -} from '@blueprintjs/core'; +import React, { useCallback, useMemo } from 'react'; +import { MenuItem, Button } from '@blueprintjs/core'; import ListSelect from 'components/ListSelect'; import { FormattedMessage as T } from 'react-intl'; export default function ContactsListField({ contacts, onContactSelected, - error, - initialContact, - defautlSelectText = () + selectedContactId, + selectedContactType, + defautlSelectText = , }) { - const [selectedContact, setSelectedContact] = useState( - initialContact || null + // Contact item of select accounts field. + const contactRenderer = useCallback( + (item, { handleClick, modifiers, query }) => ( + + ), + [], ); - // Contact item of select accounts field. - const contactItem = useCallback((item, { handleClick, modifiers, query }) => ( - - ), []); + const onContactSelect = useCallback( + (contact) => { + onContactSelected && onContactSelected(contact); + }, + [onContactSelected], + ); - const onContactSelect = useCallback((contact) => { - setSelectedContact(contact.id); - onContactSelected && onContactSelected(contact); - }, [setSelectedContact, onContactSelected]); + const items = useMemo( + () => + contacts.map((contact) => ({ + ...contact, + _id: `${contact.id}_${contact.contact_type}`, + })), + [contacts], + ); return ( } - itemRenderer={contactItem} + items={items} + noResults={} + itemRenderer={contactRenderer} popoverProps={{ minimal: true }} filterable={true} onItemSelect={onContactSelect} labelProp={'display_name'} - selectedItem={selectedContact} - selectedItemProp={'id'} - defaultText={defautlSelectText} /> + selectedItem={`${selectedContactId}_${selectedContactType}`} + selectedItemProp={'_id'} + defaultText={defautlSelectText} + /> ); -} \ No newline at end of file +} diff --git a/client/src/components/Dashboard/DashboardTopbar.js b/client/src/components/Dashboard/DashboardTopbar.js index a598c06b9..50326792a 100644 --- a/client/src/components/Dashboard/DashboardTopbar.js +++ b/client/src/components/Dashboard/DashboardTopbar.js @@ -110,10 +110,15 @@ function DashboardTopbar({ icon={} text={} /> -