aboutsummaryrefslogtreecommitdiff
path: root/src/services/SuggestedPeopleService.ts
diff options
context:
space:
mode:
authorIvan Chen <ivan@thetaggid.com>2021-02-18 14:16:23 -0500
committerGitHub <noreply@github.com>2021-02-18 14:16:23 -0500
commit2bb7b351a0e509beb9e6d87364471599af402db2 (patch)
treefe23f63de28c4f472805f952a1422a72e7c3b8a0 /src/services/SuggestedPeopleService.ts
parent99db144ce20fd5f1502f668795ae7cafbc5b2eae (diff)
parent04b998e6cca0d76c391b91403172c53f276db64a (diff)
Merge pull request #236 from IvanIFChen/tma626-people-tutorial
[TMA-626] Suggested People Tutorial (First 3 Screens)
Diffstat (limited to 'src/services/SuggestedPeopleService.ts')
-rw-r--r--src/services/SuggestedPeopleService.ts50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/services/SuggestedPeopleService.ts b/src/services/SuggestedPeopleService.ts
new file mode 100644
index 00000000..7e43c3b6
--- /dev/null
+++ b/src/services/SuggestedPeopleService.ts
@@ -0,0 +1,50 @@
+import AsyncStorage from '@react-native-community/async-storage';
+import {EDIT_PROFILE_ENDPOINT, SP_UPDATE_PICTURE} 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 (photoUri: string) => {
+ try {
+ const token = await AsyncStorage.getItem('token');
+ const form = new FormData();
+ form.append('suggested_people', {
+ uri: photoUri,
+ name: 'sp_photo.jpg',
+ type: 'image/jpg',
+ });
+ const response = await fetch(SP_UPDATE_PICTURE, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'multipart/form-data',
+ Authorization: 'Token ' + token,
+ },
+ body: form,
+ });
+ return response.status === 201;
+ } catch (error) {
+ console.log('Error uploading SP photo');
+ return false;
+ }
+};