diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-02-12 19:31:32 -0500 |
|---|---|---|
| committer | Ivan Chen <ivan@tagg.id> | 2021-02-12 19:31:32 -0500 |
| commit | 5cdde33f9c35c1d26f47d0a71ee75c635a94ee49 (patch) | |
| tree | 8edbe5cce80696e7a3aaf98e463acca4c8ba7c21 /src/services | |
| parent | dfff52bb9c7e8a284e465cd90a61ada94a8d6a4e (diff) | |
now using suggested_people_linked, moved things around
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/SuggestedPeopleService.ts | 39 | ||||
| -rw-r--r-- | src/services/UserProfileService.ts | 47 | ||||
| -rw-r--r-- | src/services/index.ts | 1 |
3 files changed, 48 insertions, 39 deletions
diff --git a/src/services/SuggestedPeopleService.ts b/src/services/SuggestedPeopleService.ts new file mode 100644 index 00000000..4be8c3a5 --- /dev/null +++ b/src/services/SuggestedPeopleService.ts @@ -0,0 +1,39 @@ +import AsyncStorage from '@react-native-community/async-storage'; +import {EDIT_PROFILE_ENDPOINT} from '../constants'; + +export const sendSuggestedPeopleLinked = async ( + userId: string, + stage: number, +) => { + try { + const request = new FormData(); + request.append('suggested_people_linked', stage); + const endpoint = EDIT_PROFILE_ENDPOINT + `${userId}/`; + const token = await AsyncStorage.getItem('token'); + let response = await fetch(endpoint, { + method: 'PATCH', + headers: { + 'Content-Type': 'multipart/form-data', + Authorization: 'Token ' + token, + }, + body: request, + }); + return response.status === 200; + } catch (error) { + console.log('Error updating animated tutorial close button press'); + return false; + } +}; + +export const sendSuggestedPeoplePhoto = async ( + useId: string, + photoUri: string, +) => { + try { + // TODO: hit endpoint here + return true; + } catch (error) { + console.log('Error uploading SP photo'); + return false; + } +}; diff --git a/src/services/UserProfileService.ts b/src/services/UserProfileService.ts index ce9bdda5..fff35370 100644 --- a/src/services/UserProfileService.ts +++ b/src/services/UserProfileService.ts @@ -2,20 +2,18 @@ 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, UserType} from '../types'; import { - PROFILE_PHOTO_ENDPOINT, - HEADER_PHOTO_ENDPOINT, GET_FB_POSTS_ENDPOINT, GET_IG_POSTS_ENDPOINT, GET_TWITTER_POSTS_ENDPOINT, - PROFILE_INFO_ENDPOINT, + HEADER_PHOTO_ENDPOINT, PASSWORD_RESET_ENDPOINT, + PROFILE_INFO_ENDPOINT, + PROFILE_PHOTO_ENDPOINT, + PROFILE_PHOTO_THUMBNAIL_ENDPOINT, + SEND_OTP_ENDPOINT, TAGG_CUSTOMER_SUPPORT, VERIFY_OTP_ENDPOINT, - SEND_OTP_ENDPOINT, - PROFILE_PHOTO_THUMBNAIL_ENDPOINT, - EDIT_PROFILE_ENDPOINT, } from '../constants'; import { ERROR_DOUBLE_CHECK_CONNECTION, @@ -28,6 +26,7 @@ import { SUCCESS_PWD_RESET, SUCCESS_VERIFICATION_CODE_SENT, } from '../constants/strings'; +import {SocialAccountType} from '../types'; export const loadProfileInfo = async (token: string, userId: string) => { try { @@ -50,16 +49,11 @@ export const loadProfileInfo = async (token: string, userId: string) => { tiktok, university_class, profile_completion_stage, - sp_swipe_tutorial, - // onboarded_sugggested_people, + suggested_people_linked, 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, @@ -70,8 +64,7 @@ export const loadProfileInfo = async (token: string, userId: string) => { tiktok, university_class, profile_completion_stage, - sp_swipe_tutorial, - onboarded_sugggested_people: false, + suggested_people_linked, friendship_status, friendship_requester_id, }; @@ -322,27 +315,3 @@ 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'); - let response = await fetch(endpoint, { - method: 'PATCH', - headers: { - 'Content-Type': 'multipart/form-data', - Authorization: 'Token ' + token, - }, - body: request, - }); - if (response.status === 200) { - return true; - } else { - return false; - } - } catch (error) { - console.log('Error updating animated tutorial close button press'); - } -}; diff --git a/src/services/index.ts b/src/services/index.ts index 9c168d4f..ef71233a 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -11,3 +11,4 @@ export * from './FCMService'; export * from './WaitlistUserService'; export * from './CommonService'; export * from './CommentService'; +export * from './SuggestedPeopleService'; |
