diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/friends/InviteFriendTile.tsx | 44 |
1 files changed, 6 insertions, 38 deletions
diff --git a/src/components/friends/InviteFriendTile.tsx b/src/components/friends/InviteFriendTile.tsx index 9967b365..c47c8764 100644 --- a/src/components/friends/InviteFriendTile.tsx +++ b/src/components/friends/InviteFriendTile.tsx @@ -1,4 +1,3 @@ -import AsyncStorage from '@react-native-community/async-storage'; import React, {useEffect, useState} from 'react'; import { Alert, @@ -11,11 +10,7 @@ import { } from 'react-native'; import {useSelector} from 'react-redux'; import {RootState} from 'src/store/rootReducer'; -import { - CREATE_INVITE_CODE, - GET_REMAINING_INVITES, - TAGG_LIGHT_BLUE, -} from '../../constants'; +import {TAGG_LIGHT_BLUE} from '../../constants'; import { ERROR_NO_CONTACT_INVITE_LEFT, ERROR_SOMETHING_WENT_WRONG, @@ -25,7 +20,11 @@ import { SUCCESS_LAST_CONTACT_INVITE, } from '../../constants/strings'; import {InviteContactType} from '../../screens/profile/InviteFriendsScreen'; -import {inviteFriendService} from '../../services'; +import { + getRemainingInviteCount, + handleCreateInviteCode, + inviteFriendService, +} from '../../services'; import {normalize} from '../../utils'; interface InviteFriendTileProps { @@ -75,37 +74,6 @@ const InviteFriendTile: React.FC<InviteFriendTileProps> = ({item}) => { } }; - const getRemainingInviteCount = async () => { - const firstName = name.split(' ')[0]; - const lastName = name.split(' ')[1]; - const token = await AsyncStorage.getItem('token'); - const response = await fetch(GET_REMAINING_INVITES, { - method: 'POST', - headers: { - Authorization: 'Token ' + token, - }, - body: JSON.stringify({ - invitee_first_name: firstName, - invitee_last_name: lastName, - }), - }); - if (response.status === 200) { - const data = await response.json(); - return data.invites_left; - } else if (response.status === 500) { - return -1; - } - }; - - const handleCreateInviteCode = async () => { - const response = await fetch(CREATE_INVITE_CODE, {method: 'POST'}); - if (response.status === 200) { - const data = await response.json(); - return data.code; - } else if (response.status === 500) { - return -1; - } - }; useEffect(() => { const formatPhoneNumer = () => { const unformatted_number: string = item.phoneNumber; |