From 2ee4ffc4c99f794941e9d3e2c7e47a145d89d83d Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 20 Apr 2021 16:44:12 -0400 Subject: added 5 invite limits --- src/constants/strings.ts | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/constants') diff --git a/src/constants/strings.ts b/src/constants/strings.ts index bdb94fba..50e4518b 100644 --- a/src/constants/strings.ts +++ b/src/constants/strings.ts @@ -30,6 +30,7 @@ export const ERROR_LINK = (str: string) => `Unable to link with ${str}, Please c export const ERROR_LOGIN = 'There was a problem logging you in, please refresh and try again'; export const ERROR_LOGIN_FAILED = 'Login failed. Check your username and password, and try again'; export const ERROR_NEXT_PAGE = 'There was a problem while loading the next page 😓, try again in a couple minutes'; +export const ERROR_NO_CONTACT_INVITE_LEFT = 'You have no more invites left!' export const ERROR_NOT_ONBOARDED = 'You are now on waitlist, please enter your invitation code if you have one'; export const ERROR_PHONE_IN_USE = 'Phone already in use, please try another one'; export const ERROR_PROFILE_CREATION_SHORT = 'Profile creation failed 😓'; @@ -62,7 +63,9 @@ export const NO_RESULTS_FOUND = 'No Results Found!'; export const PRIVATE_ACCOUNT = 'This account is private'; export const SUCCESS_BADGES_UPDATE = 'Badges updated successfully!' export const SUCCESS_CATEGORY_DELETE = 'Category successfully deleted, but its memory will live on'; +export const SUCCESS_LAST_CONTACT_INVITE = 'Done! That was your last invite, hope you used it wisely!'; export const SUCCESS_INVITATION_CODE = 'Welcome to Tagg!'; +export const SUCCESS_INVITE_CONTACT = (str: string) => `Success! You now have ${str} invites left!`; export const SUCCESS_LINK = (str: string) => `Successfully linked ${str} 🎉`; export const SUCCESS_PIC_UPLOAD = 'Beautiful, the picture was uploaded successfully!'; export const SUCCESS_PWD_RESET = 'Your password was reset successfully!'; -- cgit v1.2.3-70-g09d2 From e050709c3be4e9bae828caa6a01bfdab5f4bcfcf Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Wed, 21 Apr 2021 12:23:37 -0400 Subject: updated to use the new endpoint --- src/constants/api.ts | 1 + src/screens/profile/ProfileScreen.tsx | 9 ++++++++- src/services/UserProfileService.ts | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) (limited to 'src/constants') diff --git a/src/constants/api.ts b/src/constants/api.ts index cb45b238..dd934f0e 100644 --- a/src/constants/api.ts +++ b/src/constants/api.ts @@ -16,6 +16,7 @@ export const EDIT_PROFILE_ENDPOINT: string = API_URL + 'edit-profile/'; export const SEND_OTP_ENDPOINT: string = API_URL + 'send-otp/'; export const VERIFY_OTP_ENDPOINT: string = API_URL + 'verify-otp/'; export const USER_PROFILE_ENDPOINT: string = API_URL + 'profile/'; +export const USER_PROFILE_VISITED_ENDPOINT: string = API_URL + 'profile/visited/'; export const PROFILE_INFO_ENDPOINT: string = API_URL + 'user-profile-info/'; export const HEADER_PHOTO_ENDPOINT: string = API_URL + 'header-pic/'; export const PROFILE_PHOTO_ENDPOINT: string = API_URL + 'profile-pic/'; diff --git a/src/screens/profile/ProfileScreen.tsx b/src/screens/profile/ProfileScreen.tsx index 6d9ef020..3dd142e1 100644 --- a/src/screens/profile/ProfileScreen.tsx +++ b/src/screens/profile/ProfileScreen.tsx @@ -1,8 +1,9 @@ -import React from 'react'; +import React, {useEffect} from 'react'; import {StatusBar} from 'react-native'; import {Content, TabsGradient} from '../../components'; import {RouteProp} from '@react-navigation/native'; import {MainStackParams} from '../../routes/'; +import {visitedUserProfile} from '../../services'; type ProfileScreenRouteProps = RouteProp; @@ -14,6 +15,12 @@ const ProfileScreen: React.FC = ({route}) => { const {screenType} = route.params; let {userXId} = route.params; + useEffect(() => { + if (userXId) { + visitedUserProfile(userXId); + } + }); + return ( <> diff --git a/src/services/UserProfileService.ts b/src/services/UserProfileService.ts index 1ce1d0b5..a2237c94 100644 --- a/src/services/UserProfileService.ts +++ b/src/services/UserProfileService.ts @@ -16,6 +16,7 @@ import { SEND_OTP_ENDPOINT, TAGG_CUSTOMER_SUPPORT, USER_PROFILE_ENDPOINT, + USER_PROFILE_VISITED_ENDPOINT, VERIFY_OTP_ENDPOINT, } from '../constants'; import { @@ -412,3 +413,24 @@ export const patchEditProfile = async (form: FormData, userId: string) => { throw ERROR_DOUBLE_CHECK_CONNECTION; } }; + +export const visitedUserProfile = async (userId: string) => { + try { + const token = await AsyncStorage.getItem('token'); + const form = new FormData(); + form.append('user_id', userId); + const response = await fetch(USER_PROFILE_VISITED_ENDPOINT, { + method: 'POST', + headers: { + 'Content-Type': 'multipart/form-data', + Authorization: 'Token ' + token, + }, + body: form, + }); + if (response.status !== 200) { + console.error('Failed to submit a profile visit'); + } + } catch (error) { + return undefined; + } +}; -- cgit v1.2.3-70-g09d2