From fe5ff5ec516302811b7323cadf8e3dd0939beea4 Mon Sep 17 00:00:00 2001
From: Shravya Ramesh <shravs1208@gmail.com>
Date: Thu, 18 Mar 2021 02:45:46 -0700
Subject: services +

---
 src/screens/profile/InviteFriendsScreen.tsx | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

(limited to 'src/screens/profile/InviteFriendsScreen.tsx')

diff --git a/src/screens/profile/InviteFriendsScreen.tsx b/src/screens/profile/InviteFriendsScreen.tsx
index 8fc12a5e..1a5de1ce 100644
--- a/src/screens/profile/InviteFriendsScreen.tsx
+++ b/src/screens/profile/InviteFriendsScreen.tsx
@@ -13,7 +13,7 @@ import {
   TouchableWithoutFeedback,
 } from 'react-native';
 import {useDispatch, useStore} from 'react-redux';
-import {ProfilePreviewType, ScreenType} from '../../types';
+import {ContactType, ProfilePreviewType, ScreenType} from '../../types';
 import {
   handleAddFriend,
   HeaderHeight,
@@ -53,24 +53,30 @@ const InviteFriendsScreen: React.FC<InviteFriendsScreenProps> = ({
   });
   const [query, setQuery] = useState('');
 
-  const extractPhoneNumbers = async () => {
-    let phoneNumbers: Array<string> = [];
+  const extractContacts = async () => {
+    let retrievedContacts: Array<ContactType> = [];
     await getAll().then((contacts) => {
       contacts.map((contact) => {
+        let obj: ContactType = {
+          first_name: contact.givenName,
+          last_name: contact.familyName,
+        };
         contact.phoneNumbers.map(async (phoneNumber) => {
-          phoneNumbers.push(await phoneNumber.number);
+          obj.phone_number = phoneNumber.number;
+          retrievedContacts.push(obj);
+          console.log('contact: ', obj);
         });
       });
     });
-    return phoneNumbers;
+    return retrievedContacts;
   };
 
   useEffect(() => {
     const handleFindFriends = () => {
-      extractPhoneNumbers().then(async (phoneNumbers) => {
+      extractContacts().then(async (retrievedContacts) => {
         const permission = await checkPermission();
         if (permission === 'authorized') {
-          let response = await usersFromContactsService(phoneNumbers);
+          let response = await usersFromContactsService(retrievedContacts);
           await setUsersFromContacts(response.existing_tagg_users);
           await setNonUsersFromContacts(response.invite_from_contacts);
           usersFromContacts.map((user) => console.log('user: ', user.username));
@@ -169,6 +175,7 @@ const InviteFriendsScreen: React.FC<InviteFriendsScreenProps> = ({
   const NonUsersFromContacts = () => (
     <>
       <FlatList
+        contentContainerStyle={{paddingBottom: 130}}
         showsVerticalScrollIndicator={false}
         data={results.nonUsersFromContacts}
         keyExtractor={(item) => item.phoneNumber}
-- 
cgit v1.2.3-70-g09d2

