aboutsummaryrefslogtreecommitdiff
path: root/src/services/UserProfileService.ts
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-01-11 16:11:11 -0500
committerIvan Chen <ivan@tagg.id>2021-01-15 14:19:50 -0500
commit080e76350c2570eeb096fad40fe95f1b766b4539 (patch)
treebcb9f73f2c192f8c34f2064a5c3fd003756c2823 /src/services/UserProfileService.ts
parent1dccfb1d3e9470d81de8d1ec0a0dbb3803372f7d (diff)
created strings.ts and linting
Diffstat (limited to 'src/services/UserProfileService.ts')
-rw-r--r--src/services/UserProfileService.ts68
1 files changed, 27 insertions, 41 deletions
diff --git a/src/services/UserProfileService.ts b/src/services/UserProfileService.ts
index 793ee44d..830fbbb9 100644
--- a/src/services/UserProfileService.ts
+++ b/src/services/UserProfileService.ts
@@ -17,6 +17,17 @@ import {
SEND_OTP_ENDPOINT,
PROFILE_PHOTO_THUMBNAIL_ENDPOINT,
} from '../constants';
+import {
+ ERROR_DOUBLE_CHECK_CONNECTION,
+ ERROR_DUP_OLD_PWD,
+ ERROR_INVALID_PWD_CODE,
+ ERROR_PWD_ACCOUNT,
+ ERROR_SOMETHING_WENT_WRONG,
+ ERROR_SOMETHING_WENT_WRONG_REFRESH,
+ ERROR_VERIFICATION_FAILED,
+ SUCCESS_PWD_RESET,
+ SUCCESS_VERIFICATION_CODE_SENT,
+} from '../constants/strings';
export const loadProfileInfo = async (token: string, userId: string) => {
try {
@@ -56,10 +67,7 @@ export const loadProfileInfo = async (token: string, userId: string) => {
throw 'Unable to load profile data';
}
} catch (error) {
- Alert.alert(
- 'Something went wrong! 😭',
- "Would you believe me if I told you that I don't know what happened?",
- );
+ Alert.alert(ERROR_SOMETHING_WENT_WRONG_REFRESH);
}
};
@@ -174,10 +182,7 @@ export const handlePasswordResetRequest = async (value: string) => {
`Please make sure that the email / username entered is registered with us. You may contact our customer support at ${TAGG_CUSTOMER_SUPPORT}`,
);
} else {
- Alert.alert(
- 'Something went wrong! 😭',
- "Would you believe me if I told you that I don't know what happened?",
- );
+ Alert.alert(ERROR_SOMETHING_WENT_WRONG_REFRESH);
}
console.log(response);
@@ -185,7 +190,7 @@ export const handlePasswordResetRequest = async (value: string) => {
}
} catch (error) {
console.log(error);
- Alert.alert('Something went wrong! 😭', 'Looks like our servers are down');
+ Alert.alert(ERROR_SOMETHING_WENT_WRONG);
return false;
}
};
@@ -211,16 +216,11 @@ export const handlePasswordCodeVerification = async (
return true;
} else {
if (status == 404) {
- Alert.alert(
- `Please make sure that the email / username entered is registered with us. You may contact our customer support at ${TAGG_CUSTOMER_SUPPORT}`,
- );
+ Alert.alert(ERROR_PWD_ACCOUNT(TAGG_CUSTOMER_SUPPORT));
} else if (status === 401) {
- Alert.alert('Looks like you have entered the wrong code');
+ Alert.alert(ERROR_INVALID_PWD_CODE);
} else {
- Alert.alert(
- 'Something went wrong! 😭',
- "Would you believe me if I told you that I don't know what happened?",
- );
+ Alert.alert(ERROR_SOMETHING_WENT_WRONG);
}
console.log(response);
@@ -228,7 +228,7 @@ export const handlePasswordCodeVerification = async (
}
} catch (error) {
console.log(error);
- Alert.alert('Something went wrong! 😭', 'Looks like our servers are down');
+ Alert.alert(ERROR_SOMETHING_WENT_WRONG);
return false;
}
};
@@ -248,27 +248,22 @@ export const handlePasswordReset = async (value: string, password: string) => {
});
const status = response.status;
if (status === 200) {
- Alert.alert('Your password was reset successfully');
+ Alert.alert(SUCCESS_PWD_RESET);
return true;
} else {
if (status == 404) {
- Alert.alert(
- `Please make sure that the email / username entered is registered with us. You may contact our customer support at ${TAGG_CUSTOMER_SUPPORT}`,
- );
+ Alert.alert(ERROR_PWD_ACCOUNT(TAGG_CUSTOMER_SUPPORT));
} else if (status == 406) {
- Alert.alert('You may not use an already used password');
+ Alert.alert(ERROR_DUP_OLD_PWD);
} else {
- Alert.alert(
- 'Something went wrong! 😭',
- "Would you believe me if I told you that I don't know what happened?",
- );
+ Alert.alert(ERROR_SOMETHING_WENT_WRONG_REFRESH);
}
console.log(response);
return false;
}
} catch (error) {
console.log(error);
- Alert.alert('Something went wrong! 😭', 'Looks like our servers are down');
+ Alert.alert(ERROR_SOMETHING_WENT_WRONG);
return false;
}
};
@@ -292,17 +287,11 @@ export const verifyOtp = async (phone: string, otp: string) => {
'Try again. Tap the resend code button if you need a new code.',
);
} else {
- Alert.alert(
- 'Something went wrong! 😭',
- "Would you believe me if I told you that I don't know what happened?",
- );
+ Alert.alert(ERROR_SOMETHING_WENT_WRONG_REFRESH);
}
}
} catch (error) {
- Alert.alert(
- 'Verifiation failed 😓',
- 'Please double-check your network connection and retry.',
- );
+ Alert.alert(ERROR_VERIFICATION_FAILED, ERROR_DOUBLE_CHECK_CONNECTION);
return {
name: 'Verification error',
description: error,
@@ -322,13 +311,10 @@ export const sendOtp = async (phone: string) => {
let status = response.status;
if (status === 200) {
- Alert.alert(
- 'New verification code sent!',
- 'Check your phone messages for your code.',
- );
+ Alert.alert(SUCCESS_VERIFICATION_CODE_SENT);
return true;
} else {
- Alert.alert('Something went wrong!');
+ Alert.alert(ERROR_SOMETHING_WENT_WRONG);
return false;
}
} catch (error) {