diff options
author | Ivan Chen <ivan@thetaggid.com> | 2021-01-15 19:27:03 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-15 19:27:03 -0500 |
commit | 1803da7388902db45ad37fbac509604ae632bdb5 (patch) | |
tree | a786919f9bc42f7797367d55ed8f1e099134f368 /src/services/UserProfileService.ts | |
parent | 4d9efafeb4243e20e1fc936c27b9055c7ec82f8a (diff) | |
parent | cc52dabaaf529763e9c1c4683ba94ed55c5671a8 (diff) |
Merge pull request #176 from IvanIFChen/tma498-update-error-strings
[TMA-498] Update Error Strings
Diffstat (limited to 'src/services/UserProfileService.ts')
-rw-r--r-- | src/services/UserProfileService.ts | 68 |
1 files changed, 27 insertions, 41 deletions
diff --git a/src/services/UserProfileService.ts b/src/services/UserProfileService.ts index 793ee44d..37d00659 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_SHORT, + 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_SHORT, 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) { |