diff options
author | Shravya Ramesh <shravs1208@gmail.com> | 2021-03-18 13:44:19 -0700 |
---|---|---|
committer | Shravya Ramesh <shravs1208@gmail.com> | 2021-03-18 13:44:19 -0700 |
commit | f81a4e1a05ca3fa66c2798b047d4bfd6995f462d (patch) | |
tree | fe9507ce9fe8076d12cbf53da576bedcd46c65a5 /src/utils/common.ts | |
parent | a44e8d02c117783c19618d3af204299ae5c7a9ff (diff) |
Support modified endpoints + refactoring
Diffstat (limited to 'src/utils/common.ts')
-rw-r--r-- | src/utils/common.ts | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/utils/common.ts b/src/utils/common.ts index c1049c42..5f0e26ba 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -1,8 +1,9 @@ -import {NotificationType} from './../types/types'; +import {ContactType, NotificationType} from './../types/types'; import moment from 'moment'; import {Linking} from 'react-native'; import {BROWSABLE_SOCIAL_URLS, TOGGLE_BUTTON_TYPE} from '../constants'; import AsyncStorage from '@react-native-community/async-storage'; +import {getAll} from 'react-native-contacts'; export const getToggleButtonText: ( buttonType: string, @@ -115,3 +116,21 @@ export const shuffle = (array: any[]) => { return array; }; + +export 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) => { + obj.phone_number = phoneNumber.number; + retrievedContacts.push(obj); + console.log('contact: ', obj); + }); + }); + }); + return retrievedContacts; +}; |