From 2ee4ffc4c99f794941e9d3e2c7e47a145d89d83d Mon Sep 17 00:00:00 2001
From: Ivan Chen <ivan@tagg.id>
Date: Tue, 20 Apr 2021 16:44:12 -0400
Subject: added 5 invite limits

---
 src/components/friends/InviteFriendTile.tsx | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

(limited to 'src/components/friends/InviteFriendTile.tsx')

diff --git a/src/components/friends/InviteFriendTile.tsx b/src/components/friends/InviteFriendTile.tsx
index 95ebf16a..5237389a 100644
--- a/src/components/friends/InviteFriendTile.tsx
+++ b/src/components/friends/InviteFriendTile.tsx
@@ -8,25 +8,37 @@ import {
   View,
 } from 'react-native';
 import {TAGG_LIGHT_BLUE} from '../../constants';
-import {ERROR_SOMETHING_WENT_WRONG} from '../../constants/strings';
+import {
+  ERROR_NO_CONTACT_INVITE_LEFT,
+  ERROR_SOMETHING_WENT_WRONG,
+  SUCCESS_INVITE_CONTACT,
+  SUCCESS_LAST_CONTACT_INVITE,
+} from '../../constants/strings';
+import {InviteContactType} from '../../screens/profile/InviteFriendsScreen';
 import {inviteFriendService} from '../../services';
 import {normalize} from '../../utils';
 
 interface InviteFriendTileProps {
-  item: Object;
+  item: InviteContactType;
 }
 
 const InviteFriendTile: React.FC<InviteFriendTileProps> = ({item}) => {
   const [invited, setInvited] = useState<boolean>(false);
   const [formatedPhoneNumber, setFormattedPhoneNumber] = useState<string>('');
   const handleInviteFriend = async () => {
-    const response = await inviteFriendService(
+    const invites_left = await inviteFriendService(
       item.phoneNumber,
       item.firstName,
       item.lastName,
     );
-    if (response) {
-      setInvited(response);
+    if (invites_left > 0) {
+      setInvited(true);
+      Alert.alert(SUCCESS_INVITE_CONTACT(invites_left));
+    } else if (invites_left === 0) {
+      setInvited(true);
+      Alert.alert(SUCCESS_LAST_CONTACT_INVITE);
+    } else if (invites_left === -1) {
+      Alert.alert(ERROR_NO_CONTACT_INVITE_LEFT);
     } else {
       Alert.alert(ERROR_SOMETHING_WENT_WRONG);
     }
-- 
cgit v1.2.3-70-g09d2

