aboutsummaryrefslogtreecommitdiff
path: root/src/services/UserProfileService.ts
diff options
context:
space:
mode:
authorShravya Ramesh <shravs1208@gmail.com>2021-02-11 07:00:17 -0800
committerShravya Ramesh <shravs1208@gmail.com>2021-02-11 07:00:17 -0800
commit84c88301710de2a2500e89191bdef49846b34f12 (patch)
treecaa4bf5c9c5993635b2d614c119240d5cbd66395 /src/services/UserProfileService.ts
parentfb76f7ac90e60c9792ff857544489dd0fa4d0e2a (diff)
added async function to services for backend call
Diffstat (limited to 'src/services/UserProfileService.ts')
-rw-r--r--src/services/UserProfileService.ts35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/services/UserProfileService.ts b/src/services/UserProfileService.ts
index d0610714..39c99f33 100644
--- a/src/services/UserProfileService.ts
+++ b/src/services/UserProfileService.ts
@@ -2,7 +2,7 @@ import AsyncStorage from '@react-native-community/async-storage';
import moment from 'moment';
import {Alert} from 'react-native';
import RNFetchBlob from 'rn-fetch-blob';
-import {SocialAccountType} from '../types';
+import {SocialAccountType, UserType} from '../types';
import {
PROFILE_PHOTO_ENDPOINT,
HEADER_PHOTO_ENDPOINT,
@@ -15,6 +15,7 @@ import {
VERIFY_OTP_ENDPOINT,
SEND_OTP_ENDPOINT,
PROFILE_PHOTO_THUMBNAIL_ENDPOINT,
+ EDIT_PROFILE_ENDPOINT,
} from '../constants';
import {
ERROR_DOUBLE_CHECK_CONNECTION,
@@ -49,10 +50,15 @@ export const loadProfileInfo = async (token: string, userId: string) => {
tiktok,
university_class,
profile_completion_stage,
+ sp_swipe_tutorial,
friendship_status,
friendship_requester_id,
} = info;
birthday = birthday && moment(birthday).format('YYYY-MM-DD');
+ console.log(
+ 'Suggested People loaded from backend for logged in user: ',
+ sp_swipe_tutorial,
+ );
return {
name,
biography,
@@ -63,6 +69,7 @@ export const loadProfileInfo = async (token: string, userId: string) => {
tiktok,
university_class,
profile_completion_stage,
+ sp_swipe_tutorial,
friendship_status,
friendship_requester_id,
};
@@ -313,3 +320,29 @@ export const sendOtp = async (phone: string) => {
return false;
}
};
+
+export const editSPSwipeTutorial = async (user: UserType) => {
+ try {
+ const request = new FormData();
+ request.append('sp_swipe_tutorial', 1);
+ const endpoint = EDIT_PROFILE_ENDPOINT + `${user.userId}/`;
+ const token = await AsyncStorage.getItem('token');
+ console.log('token: ', token);
+ let response = await fetch(endpoint, {
+ method: 'PATCH',
+ headers: {
+ 'Content-Type': 'multipart/form-data',
+ Authorization: 'Token ' + token,
+ },
+ body: request,
+ });
+ if (response.status === 200) {
+ console.log('updatedbackend');
+ return true;
+ } else {
+ return false;
+ }
+ } catch (error) {
+ console.log('Error updating animated tutorial close button press');
+ }
+};