diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-03-29 14:02:31 -0400 |
|---|---|---|
| committer | Ivan Chen <ivan@tagg.id> | 2021-03-29 14:02:31 -0400 |
| commit | 04bf806285e7626644234b7febee2dad5c912f8d (patch) | |
| tree | 9ed3ec581792d6a0e1135f02a1d4716890ca75fc /src/screens/profile/EditProfile.tsx | |
| parent | e8324a7278a82d926acceedc10921f0b14e6d403 (diff) | |
| parent | 4de1ebd43437712e28a89bb624c5b12afad45cc6 (diff) | |
Merge branch 'master' into tma-701-private-account-banner
# Conflicts:
# src/constants/strings.ts
Diffstat (limited to 'src/screens/profile/EditProfile.tsx')
| -rw-r--r-- | src/screens/profile/EditProfile.tsx | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/src/screens/profile/EditProfile.tsx b/src/screens/profile/EditProfile.tsx index 56bed11f..8afaeb6d 100644 --- a/src/screens/profile/EditProfile.tsx +++ b/src/screens/profile/EditProfile.tsx @@ -46,6 +46,7 @@ import { ERROR_UPLOAD_SMALL_PROFILE_PIC, } from '../../constants/strings'; import TaggLoadingIndicator from '../../components/common/TaggLoadingIndicator'; +import {patchEditProfile} from '../../services'; type EditProfileNavigationProp = StackNavigationProp< MainStackParams, @@ -364,38 +365,15 @@ const EditProfile: React.FC<EditProfileProps> = ({route, navigation}) => { return; } - const endpoint = EDIT_PROFILE_ENDPOINT + `${userId}/`; - try { - const token = await AsyncStorage.getItem('token'); - let response = await fetch(endpoint, { - method: 'PATCH', - headers: { - 'Content-Type': 'multipart/form-data', - Authorization: 'Token ' + token, - }, - body: request, - }); - let statusCode = response.status; - let data = await response.json(); - if (statusCode === 200) { + patchEditProfile(request, userId) + .then((_) => { setNeedsUpdate(true); navigation.pop(); - } else if (statusCode === 400) { - Alert.alert( - 'Profile update failed. 😔', - data.error || 'Something went wrong! ðŸ˜', - ); - } else { - Alert.alert(ERROR_SOMETHING_WENT_WRONG_REFRESH); - } - } catch (error) { - Alert.alert(ERROR_DOUBLE_CHECK_CONNECTION); - return { - name: 'Profile creation error', - description: error, - }; - } - }, [isCustomGender, form, navigation, userId]); + }) + .catch((error) => { + Alert.alert(error); + }); + }, [form, isCustomGender, university_class, userId, navigation]); React.useLayoutEffect(() => { navigation.setOptions({ |
