1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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;
}
};
|