From 4c1629e4dc3427a65157a1dae99efbb19f58ff47 Mon Sep 17 00:00:00 2001 From: Anton Stjernquist Date: Wed, 7 Feb 2024 12:49:44 +0100 Subject: [PATCH] feat(contacts): add referal, select contact from other apps (#1135) --- .../contacts/components/List/ContactItem.tsx | 43 ------------------- .../contacts/components/List/ContactList.tsx | 39 +++++++++-------- 2 files changed, 22 insertions(+), 60 deletions(-) delete mode 100644 apps/phone/src/apps/contacts/components/List/ContactItem.tsx diff --git a/apps/phone/src/apps/contacts/components/List/ContactItem.tsx b/apps/phone/src/apps/contacts/components/List/ContactItem.tsx deleted file mode 100644 index cbb53c5c3..000000000 --- a/apps/phone/src/apps/contacts/components/List/ContactItem.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { ListItemText, ListItem, ListItemAvatar, Avatar as MuiAvatar } from '@mui/material'; -import React from 'react'; - -interface ContactItemProps { - id: number; - display: string; - number: string; - avatar: string; - render: React.ReactNode; -} - -export const ContactItem: React.FC = ({ - id, - display, - number, - avatar, - render, -}) => { - return ( - - - {avatar ? ( - - ) : ( - {display.slice(0, 1).toUpperCase()} - )} - - - {render} - - ); -}; diff --git a/apps/phone/src/apps/contacts/components/List/ContactList.tsx b/apps/phone/src/apps/contacts/components/List/ContactList.tsx index a3d596bc4..b160f6094 100644 --- a/apps/phone/src/apps/contacts/components/List/ContactList.tsx +++ b/apps/phone/src/apps/contacts/components/List/ContactList.tsx @@ -1,9 +1,8 @@ import React from 'react'; import { SearchContacts } from './SearchContacts'; -import { Link, useHistory } from 'react-router-dom'; +import { Link, useHistory, useLocation } from 'react-router-dom'; import { useFilteredContacts } from '../../hooks/state'; import { Contact } from '@typings/contact'; -import { classNames } from '@utils/css'; import { useCall } from '@os/call/hooks/useCall'; import useMessages from '@apps/messages/hooks/useMessages'; import LogDebugEvent from '@os/debug/LogDebugEvents'; @@ -12,6 +11,7 @@ import { useMyPhoneNumber } from '@os/simcard/hooks/useMyPhoneNumber'; import { Phone, MessageSquare, Plus } from 'lucide-react'; import { List, ListItem, NPWDButton } from '@npwd/keyos'; import { initials } from '@utils/misc'; +import { useQueryParams } from '@common/hooks/useQueryParams'; export const ContactList: React.FC = () => { const filteredContacts = useFilteredContacts(); @@ -64,7 +64,14 @@ export const ContactList: React.FC = () => { ); }; -const ContactItem = (contact: Contact) => { +interface ContactItemProps extends Contact { + onClick?: () => void; +} + +const ContactItem = ({ number, avatar, id, display }: ContactItemProps) => { + const query = useQueryParams<{ referal: string }>(); + const { referal } = query; + const { initializeCall } = useCall(); const { goToConversation } = useMessages(); const { findExistingConversation } = useContactActions(); @@ -79,14 +86,14 @@ const ContactItem = (contact: Contact) => { level: 2, data: true, }); - initializeCall(contact.number.toString()); + initializeCall(number.toString()); }; const handleMessage = (e) => { e.stopPropagation(); e.preventDefault(); - const phoneNumber = contact.number.toString(); + const phoneNumber = number.toString(); LogDebugEvent({ action: 'Routing to Message', level: 1, @@ -104,28 +111,26 @@ const ContactItem = (contact: Contact) => {
- {contact.avatar && contact.avatar.length > 0 ? ( - {'avatar'} + {avatar && avatar.length > 0 ? ( + {'avatar'} ) : (
- - {initials(contact.display)} - + {initials(display)}
)}

- {contact.display} + {display}

-

{contact.number}

+

{number}