aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/moments/Moment.tsx24
-rw-r--r--src/components/onboarding/LinkSocialMedia.tsx5
-rw-r--r--src/components/profile/Content.tsx2
-rw-r--r--src/components/profile/MomentMoreInfoDrawer.tsx7
-rw-r--r--src/components/profile/ProfilePreview.tsx3
-rw-r--r--src/components/taggs/Tagg.tsx17
-rw-r--r--src/constants/strings.ts47
-rw-r--r--src/screens/onboarding/CategorySelection.tsx5
-rw-r--r--src/screens/onboarding/InvitationCodeVerification.tsx17
-rw-r--r--src/screens/onboarding/Login.tsx50
-rw-r--r--src/screens/onboarding/ProfileOnboarding.tsx24
-rw-r--r--src/screens/onboarding/RegistrationOne.tsx10
-rw-r--r--src/screens/onboarding/RegistrationThree.tsx17
-rw-r--r--src/screens/onboarding/RegistrationTwo.tsx6
-rw-r--r--src/screens/onboarding/Verification.tsx10
-rw-r--r--src/screens/profile/CaptionScreen.tsx21
-rw-r--r--src/screens/profile/EditProfile.tsx17
-rw-r--r--src/services/BlockUserService.ts23
-rw-r--r--src/services/MomentCategoryService.ts7
-rw-r--r--src/services/MomentServices.ts31
-rw-r--r--src/services/ReportingService.ts10
-rw-r--r--src/services/SocialLinkingService.ts12
-rw-r--r--src/services/UserFriendsServices.ts11
-rw-r--r--src/services/UserProfileService.ts68
24 files changed, 232 insertions, 212 deletions
diff --git a/src/components/moments/Moment.tsx b/src/components/moments/Moment.tsx
index 6dbcd170..7905e8a9 100644
--- a/src/components/moments/Moment.tsx
+++ b/src/components/moments/Moment.tsx
@@ -1,27 +1,20 @@
import {useNavigation} from '@react-navigation/native';
import React, {Fragment} from 'react';
-import {
- Alert,
- StyleProp,
- StyleSheet,
- View,
- ViewProps,
- ViewStyle,
-} from 'react-native';
+import {Alert, StyleProp, StyleSheet, View, ViewStyle} from 'react-native';
import {Text} from 'react-native-animatable';
import {ScrollView, TouchableOpacity} from 'react-native-gesture-handler';
+import ImagePicker from 'react-native-image-crop-picker';
import LinearGradient from 'react-native-linear-gradient';
-import PlusIcon from '../../assets/icons/plus_icon-01.svg';
-import UpIcon from '../../assets/icons/up_icon.svg';
-import DownIcon from '../../assets/icons/down_icon.svg';
+import {MomentType, ScreenType} from 'src/types';
import DeleteIcon from '../../assets/icons/delete-logo.svg';
+import DownIcon from '../../assets/icons/down_icon.svg';
+import PlusIcon from '../../assets/icons/plus_icon-01.svg';
import BigPlusIcon from '../../assets/icons/plus_icon-02.svg';
+import UpIcon from '../../assets/icons/up_icon.svg';
import {TAGG_TEXT_LIGHT_BLUE} from '../../constants';
+import {ERROR_UPLOAD_MOMENT_SHORT} from '../../constants/strings';
import {SCREEN_WIDTH} from '../../utils';
-import ImagePicker from 'react-native-image-crop-picker';
import MomentTile from './MomentTile';
-import {MomentType, ScreenType} from 'src/types';
-import {useDispatch} from 'react-redux';
interface MomentProps {
title: string;
@@ -49,7 +42,6 @@ const Moment: React.FC<MomentProps> = ({
externalStyles,
}) => {
const navigation = useNavigation();
- const dispatch = useDispatch();
const navigateToImagePicker = () => {
ImagePicker.openPicker({
@@ -77,7 +69,7 @@ const Moment: React.FC<MomentProps> = ({
})
.catch((err) => {
if (err.code && err.code !== 'E_PICKER_CANCELLED') {
- Alert.alert('Unable to upload moment!');
+ Alert.alert(ERROR_UPLOAD_MOMENT_SHORT);
}
});
};
diff --git a/src/components/onboarding/LinkSocialMedia.tsx b/src/components/onboarding/LinkSocialMedia.tsx
index c7b0a6b4..6cb7e9cf 100644
--- a/src/components/onboarding/LinkSocialMedia.tsx
+++ b/src/components/onboarding/LinkSocialMedia.tsx
@@ -13,6 +13,7 @@ import {
SOCIAL_FONT_COLORS,
TAGG_ICON_DIM,
} from '../../constants/constants';
+import {ERROR_LINK, SUCCESS_LINK} from '../../constants/strings';
import {
handlePressForAuthBrowser,
registerNonIntegratedSocialLink,
@@ -64,12 +65,12 @@ const SocialMediaLinker: React.FC<SocialMediaLinkerProps> = ({
const linkNonIntegratedSocial = async (username: string) => {
if (await registerNonIntegratedSocialLink(label, username)) {
- Alert.alert(`Successfully linked ${label} πŸŽ‰`);
+ Alert.alert(SUCCESS_LINK(label));
setAuthenticated(true);
} else {
// If we display too fast the alert will get dismissed with the modal
setTimeout(() => {
- Alert.alert(`Something went wrong, we can't link with ${label} πŸ˜”`);
+ Alert.alert(ERROR_LINK(label));
}, 500);
}
};
diff --git a/src/components/profile/Content.tsx b/src/components/profile/Content.tsx
index 1d639a41..50516b55 100644
--- a/src/components/profile/Content.tsx
+++ b/src/components/profile/Content.tsx
@@ -296,7 +296,7 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => {
momentCategories.filter((mc) => mc !== category),
false,
),
- );
+ )
dispatch(deleteUserMomentsForCategory(category));
},
},
diff --git a/src/components/profile/MomentMoreInfoDrawer.tsx b/src/components/profile/MomentMoreInfoDrawer.tsx
index e127e05c..77c349ca 100644
--- a/src/components/profile/MomentMoreInfoDrawer.tsx
+++ b/src/components/profile/MomentMoreInfoDrawer.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import {Alert, StyleSheet, TouchableOpacity, ViewProps} from 'react-native';
import MoreIcon from '../../assets/icons/more_horiz-24px.svg';
+import {ERROR_DELETE_MOMENT, MOMENT_DELETED_MSG} from '../../constants/strings';
import {deleteMoment, sendReport} from '../../services';
import {GenericMoreInfoDrawer} from '../common';
@@ -21,7 +22,7 @@ const MomentMoreInfoDrawer: React.FC<MomentMoreInfoDrawerProps> = (props) => {
if (success) {
// set time out for UI transitions
setTimeout(() => {
- Alert.alert('Moment deleted!', '', [
+ Alert.alert(MOMENT_DELETED_MSG, '', [
{
text: 'OK',
onPress: () => dismissScreenAndUpdate(),
@@ -31,9 +32,7 @@ const MomentMoreInfoDrawer: React.FC<MomentMoreInfoDrawerProps> = (props) => {
}, 500);
} else {
setTimeout(() => {
- Alert.alert(
- 'We were unable to delete that moment 😭 , please try again later!',
- );
+ Alert.alert(ERROR_DELETE_MOMENT);
}, 500);
}
});
diff --git a/src/components/profile/ProfilePreview.tsx b/src/components/profile/ProfilePreview.tsx
index 134e94cd..23cb2155 100644
--- a/src/components/profile/ProfilePreview.tsx
+++ b/src/components/profile/ProfilePreview.tsx
@@ -21,6 +21,7 @@ import {logout} from '../../store/actions';
import {fetchUserX, userXInStore} from '../../utils';
import {SearchResultsBackground} from '../search';
import NavigationBar from 'src/routes/tabs';
+import {ERROR_UNABLE_TO_VIEW_PROFILE} from '../../constants/strings';
const NO_USER: UserType = {
userId: '',
@@ -96,7 +97,7 @@ const ProfilePreview: React.FC<ProfilePreviewProps> = ({
//If the logged in user is blocked by the user being viewed, do not proceed.
const isUserBlocked = await checkIfUserIsBlocked(user.id);
if (isUserBlocked) {
- Alert.alert('You cannot view this profile');
+ Alert.alert(ERROR_UNABLE_TO_VIEW_PROFILE);
return;
}
const jsonValue = await AsyncStorage.getItem(
diff --git a/src/components/taggs/Tagg.tsx b/src/components/taggs/Tagg.tsx
index 12172df9..82ac07df 100644
--- a/src/components/taggs/Tagg.tsx
+++ b/src/components/taggs/Tagg.tsx
@@ -17,6 +17,11 @@ import {
} from '../../services';
import {SmallSocialIcon, SocialIcon, SocialLinkModal} from '../common';
import {UserType} from '../../types';
+import {
+ ERROR_LINK,
+ ERROR_UNABLE_TO_FIND_PROFILE,
+ SUCCESS_LINK,
+} from '../../constants/strings';
interface TaggProps {
social: string;
@@ -56,7 +61,7 @@ const Tagg: React.FC<TaggProps> = ({
show auth browser
case !integrated_social:
show modal
- Tagg's "Tagg" will use the Ring instead of PurpleRing
+ Tagg's "Tagg" will use the Ring instead of PurpleRing
*/
const modalOrAuthBrowserOrPass = async () => {
@@ -71,7 +76,7 @@ const Tagg: React.FC<TaggProps> = ({
if (socialURL) {
Linking.openURL(socialURL);
} else {
- Alert.alert('We were unable to find this profile πŸ˜”');
+ Alert.alert(ERROR_UNABLE_TO_FIND_PROFILE);
}
});
}
@@ -79,7 +84,9 @@ const Tagg: React.FC<TaggProps> = ({
if (isIntegrated) {
handlePressForAuthBrowser(social).then((success) => {
setTaggsNeedUpdate(success);
- if (success) setSocialDataNeedUpdate(social, '');
+ if (success) {
+ setSocialDataNeedUpdate(social, '');
+ }
});
} else {
setModalVisible(true);
@@ -105,13 +112,13 @@ const Tagg: React.FC<TaggProps> = ({
const linkNonIntegratedSocial = async (username: string) => {
if (await registerNonIntegratedSocialLink(social, username)) {
- Alert.alert(`Successfully linked ${social} πŸŽ‰`);
+ Alert.alert(SUCCESS_LINK(social));
setTaggsNeedUpdate(true);
setSocialDataNeedUpdate(social, username);
} else {
// If we display too fast the alert will get dismissed with the modal
setTimeout(() => {
- Alert.alert(`Something went wrong, we can't link with ${social} πŸ˜”`);
+ Alert.alert(ERROR_LINK(social));
}, 500);
}
};
diff --git a/src/constants/strings.ts b/src/constants/strings.ts
new file mode 100644
index 00000000..b5344afd
--- /dev/null
+++ b/src/constants/strings.ts
@@ -0,0 +1,47 @@
+/* eslint-disable */
+// Below is the regex to convert this into a csv for the Google Sheet
+// export const (.*) = .*?(['|"|`])(.*)\2;
+// replace with: $1\t$3
+export const COMING_SOON_MSG = 'Creating more fun things for you, surprises coming soon πŸ˜‰';
+export const ERROR_AUTHENTICATION = 'An error occurred during authentication. Please login again!';
+export const ERROR_CATEGORY_CREATION = 'There was a problem creating your categories. Please refresh and try again.';
+export const ERROR_CATEGORY_UPDATE = 'There was a problem updating your categories. Please refresh and try again';
+export const ERROR_DELETE_CATEGORY = 'There was a problem while deleting category. Please try again';
+export const ERROR_DELETE_MOMENT = 'Unable to delete moment, please try again later!';
+export const ERROR_DOUBLE_CHECK_CONNECTION = 'Please double-check your network connection and retry';
+export const ERROR_DUP_OLD_PWD = 'You may not use a previously used password';
+export const ERROR_EMAIL_IN_USE = 'Email already in use, please try another one';
+export const ERROR_FAILED_LOGIN_INFO = 'Login failed, please try re-entering your login information';
+export const ERROR_FAILED_TO_COMMENT = 'Unable to post comment, refresh and try again!';
+export const ERROR_INVALID_INVITATION_CODE = 'Invitation code invalid, try again or talk to the friend that sent it 😬';
+export const ERROR_INVALID_LOGIN = 'Invalid login, Please login again';
+export const ERROR_INVALID_PWD_CODE = 'Looks like you have entered the wrong code, please try again';
+export const ERROR_INVALID_VERIFICATION_CODE = 'Invalid verification code, try re-entering or tap the resend code button for a new code';
+export const ERROR_INVALID_VERIFICATION_CODE_FORMAT = 'Please enter the 6 digit code sent to your phone';
+export const ERROR_INVLAID_CODE = 'The code entered is not valid!';
+export const ERROR_LINK = (str: string) => `Unable to link with ${str}, Please check your login and try again`;
+export const ERROR_LOGIN = 'There was a problem logging you in, please refresh and try again';
+export const ERROR_LOGIN_FAILED = 'Login failed. Check your username and passoword, and try again';
+export const ERROR_NEXT_PAGE = 'There was a problem while loading the next page πŸ˜“, try again in a couple minutes';
+export const ERROR_PROFILE_CREATION_SHORT = 'Profile creation failed πŸ˜“';
+export const ERROR_PWD_ACCOUNT = (str: string) => `Please make sure that the email / username entered is registered with us. You may contact our customer support at ${str}`;
+export const ERROR_REGISTRATION = (str: string) => `Registration failed πŸ˜”, ${str}`;
+export const ERROR_SELECT_CLASS_YEAR = 'Please select your Class Year';
+export const ERROR_SERVER_DOWN = 'mhm, looks like our servers are down, please refresh and try again in a few mins';
+export const ERROR_SOMETHING_WENT_WRONG = "Oh dear, don’t worry someone will be held responsible for this error, In the meantime refresh the app";
+export const ERROR_SOMETHING_WENT_WRONG_REFRESH = "Ha, looks like this one's on us, please refresh and try again";
+export const ERROR_SOMETHING_WENT_WRONG_RELOAD = "You broke it, Just kidding! we don't know what happened... Please reload the app and try again";
+export const ERROR_UNABLE_TO_FIND_PROFILE = 'We were unable to find this profile. Please check username and try again';
+export const ERROR_UNABLE_TO_VIEW_PROFILE = 'Unable to view this profile';
+export const ERROR_UPLOAD = 'An error occurred while uploading. Please try again!';
+export const ERROR_UPLOAD_LARGE_PROFILE_PIC = "Can't have the first image seen on the profile be blank, please upload a large picture";
+export const ERROR_UPLOAD_MOMENT = 'Unable to upload moment. Please retry';
+export const ERROR_UPLOAD_SMALL_PROFILE_PIC = "Can't have a profile without a pic to represent you, please upload a small profile picture";
+export const ERROR_VERIFICATION_FAILED_SHORT = 'Verification failed πŸ˜“';
+export const MARKED_AS_MSG = (str: string) => `Marked as ${str}`;
+export const MOMENT_DELETED_MSG = 'Moment deleted....Some moments have to go, to create space for greater ones';
+export const SUCCESS_CATEGORY_DELETE = 'Category successfully deleted, but its memory will live on';
+export const SUCCESS_LINK = (str: string) => `Successfully linked ${str} πŸŽ‰`;
+export const SUCCESS_PIC_UPLOAD = 'Beautiful, the picture was uploaded successfully!';
+export const SUCCESS_PWD_RESET = 'Your password was reset successfully!';
+export const SUCCESS_VERIFICATION_CODE_SENT = 'New verification code sent! Check your phone messages for your code';
diff --git a/src/screens/onboarding/CategorySelection.tsx b/src/screens/onboarding/CategorySelection.tsx
index 5589ea9e..a3acbbb7 100644
--- a/src/screens/onboarding/CategorySelection.tsx
+++ b/src/screens/onboarding/CategorySelection.tsx
@@ -15,11 +15,12 @@ import {useDispatch, useSelector} from 'react-redux';
import PlusIcon from '../../assets/icons/plus_icon-01.svg';
import {Background, MomentCategory} from '../../components';
import {MOMENT_CATEGORIES} from '../../constants';
+import {ERROR_SOMETHING_WENT_WRONG} from '../../constants/strings';
import {OnboardingStackParams} from '../../routes';
import {fcmService, postMomentCategories} from '../../services';
import {
- updateMomentCategories,
updateIsOnboardedUser,
+ updateMomentCategories,
} from '../../store/actions/';
import {RootState} from '../../store/rootReducer';
import {BackgroundGradientType, CategorySelectionScreenType} from '../../types';
@@ -180,7 +181,7 @@ const CategorySelection: React.FC<CategorySelectionProps> = ({
}
} catch (error) {
console.log(error);
- Alert.alert('There was a problem');
+ Alert.alert(ERROR_SOMETHING_WENT_WRONG);
}
};
diff --git a/src/screens/onboarding/InvitationCodeVerification.tsx b/src/screens/onboarding/InvitationCodeVerification.tsx
index cc7cd678..903a9912 100644
--- a/src/screens/onboarding/InvitationCodeVerification.tsx
+++ b/src/screens/onboarding/InvitationCodeVerification.tsx
@@ -31,6 +31,12 @@ import {
} from 'react-native';
import {BackgroundGradientType} from '../../types';
+import {
+ ERROR_DOUBLE_CHECK_CONNECTION,
+ ERROR_INVALID_INVITATION_CODE,
+ ERROR_INVLAID_CODE,
+ ERROR_VERIFICATION_FAILED_SHORT,
+} from '../../constants/strings';
type InvitationCodeVerificationScreenNavigationProp = StackNavigationProp<
OnboardingStackParams,
@@ -66,23 +72,20 @@ const InvitationCodeVerification: React.FC<InvitationCodeVerificationProps> = ({
},
);
- if (verifyInviteCodeResponse.status == 200) {
+ if (verifyInviteCodeResponse.status === 200) {
navigation.navigate('RegistrationOne');
} else {
- Alert.alert('Invalid invitation code πŸ€”');
+ Alert.alert(ERROR_INVALID_INVITATION_CODE);
}
} 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,
};
}
} else {
- Alert.alert('The code entered is not valid!');
+ Alert.alert(ERROR_INVLAID_CODE);
}
};
diff --git a/src/screens/onboarding/Login.tsx b/src/screens/onboarding/Login.tsx
index d1717fc1..8974e000 100644
--- a/src/screens/onboarding/Login.tsx
+++ b/src/screens/onboarding/Login.tsx
@@ -1,30 +1,37 @@
-import React, {useEffect, useRef, useState} from 'react';
+import AsyncStorage from '@react-native-community/async-storage';
import {RouteProp} from '@react-navigation/native';
import {StackNavigationProp} from '@react-navigation/stack';
+import React, {useEffect, useRef, useState} from 'react';
import {
- View,
- Text,
Alert,
- StatusBar,
Image,
- TouchableOpacity,
- StyleSheet,
KeyboardAvoidingView,
Platform,
+ StatusBar,
+ StyleSheet,
+ Text,
+ TouchableOpacity,
+ View,
} from 'react-native';
-import {fcmService} from '../../services';
-import {OnboardingStackParams} from '../../routes/onboarding';
-import {Background, TaggInput, SubmitButton} from '../../components';
+import SplashScreen from 'react-native-splash-screen';
+import {useDispatch} from 'react-redux';
+import {Background, SubmitButton, TaggInput} from '../../components';
import {
- usernameRegex,
LOGIN_ENDPOINT,
TAGG_LIGHT_PURPLE,
+ usernameRegex,
} from '../../constants';
-import AsyncStorage from '@react-native-community/async-storage';
+import {
+ ERROR_DOUBLE_CHECK_CONNECTION,
+ ERROR_FAILED_LOGIN_INFO,
+ ERROR_INVALID_LOGIN,
+ ERROR_LOGIN_FAILED,
+ ERROR_SOMETHING_WENT_WRONG_REFRESH,
+} from '../../constants/strings';
+import {OnboardingStackParams} from '../../routes/onboarding';
+import {fcmService} from '../../services';
import {BackgroundGradientType, UserType} from '../../types';
-import {useDispatch} from 'react-redux';
import {userLogin} from '../../utils';
-import SplashScreen from 'react-native-splash-screen';
type VerificationScreenRouteProp = RouteProp<OnboardingStackParams, 'Login'>;
type VerificationScreenNavigationProp = StackNavigationProp<
@@ -167,28 +174,19 @@ const Login: React.FC<LoginProps> = ({navigation}: LoginProps) => {
} catch (err) {
setUser(NO_USER);
console.log(data);
- Alert.alert('Auth token storage failed', 'Please login again!');
+ Alert.alert(ERROR_INVALID_LOGIN);
}
} else if (statusCode === 401) {
- Alert.alert(
- 'Login failed πŸ˜”',
- 'Try re-entering your login information.',
- );
+ Alert.alert(ERROR_FAILED_LOGIN_INFO);
} 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);
}
} else {
setForm({...form, attemptedSubmit: false});
setTimeout(() => setForm({...form, attemptedSubmit: true}));
}
} catch (error) {
- Alert.alert(
- 'Login failed πŸ˜“',
- 'Please double-check your network connection and retry.',
- );
+ Alert.alert(ERROR_LOGIN_FAILED, ERROR_DOUBLE_CHECK_CONNECTION);
return {
name: 'Login error',
description: error,
diff --git a/src/screens/onboarding/ProfileOnboarding.tsx b/src/screens/onboarding/ProfileOnboarding.tsx
index 1f8e58da..127cd9cd 100644
--- a/src/screens/onboarding/ProfileOnboarding.tsx
+++ b/src/screens/onboarding/ProfileOnboarding.tsx
@@ -32,6 +32,14 @@ import {BackgroundGradientType} from '../../types';
import {PickerSelectProps} from 'react-native-picker-select';
import Animated from 'react-native-reanimated';
import {SCREEN_WIDTH} from '../../utils';
+import {
+ ERROR_DOUBLE_CHECK_CONNECTION,
+ ERROR_PROFILE_CREATION_SHORT,
+ ERROR_SELECT_CLASS_YEAR,
+ ERROR_SOMETHING_WENT_WRONG_REFRESH,
+ ERROR_UPLOAD_LARGE_PROFILE_PIC,
+ ERROR_UPLOAD_SMALL_PROFILE_PIC,
+} from '../../constants/strings';
type ProfileOnboardingScreenRouteProp = RouteProp<
OnboardingStackParams,
@@ -260,15 +268,15 @@ const ProfileOnboarding: React.FC<ProfileOnboardingProps> = ({
const handleSubmit = async () => {
if (!form.largePic) {
- Alert.alert('Please select a Header image!');
+ Alert.alert(ERROR_UPLOAD_LARGE_PROFILE_PIC);
return;
}
if (!form.smallPic) {
- Alert.alert('Please select a Profile Picture!');
+ Alert.alert(ERROR_UPLOAD_SMALL_PROFILE_PIC);
return;
}
if (form.classYear === -1) {
- Alert.alert('Please select Class Year');
+ Alert.alert(ERROR_SELECT_CLASS_YEAR);
return;
}
if (!form.attemptedSubmit) {
@@ -363,16 +371,10 @@ const ProfileOnboarding: React.FC<ProfileOnboardingProps> = ({
data.error || 'Something went wrong! 😭',
);
} 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(
- 'Profile creation failed πŸ˜“',
- 'Please double-check your network connection and retry.',
- );
+ Alert.alert(ERROR_PROFILE_CREATION_SHORT, ERROR_DOUBLE_CHECK_CONNECTION);
return {
name: 'Profile creation error',
description: error,
diff --git a/src/screens/onboarding/RegistrationOne.tsx b/src/screens/onboarding/RegistrationOne.tsx
index 54c4e210..2a1d884d 100644
--- a/src/screens/onboarding/RegistrationOne.tsx
+++ b/src/screens/onboarding/RegistrationOne.tsx
@@ -28,6 +28,7 @@ import {SEND_OTP_ENDPOINT} from '../../constants';
import {phoneRegex} from '../../constants';
import {BackgroundGradientType, VerificationScreenType} from '../../types';
+import {ERROR_EMAIL_IN_USE, ERROR_SERVER_DOWN} from '../../constants/strings';
type RegistrationScreenOneRouteProp = RouteProp<
OnboardingStackParams,
@@ -96,14 +97,9 @@ const RegistrationOne: React.FC<RegistrationOneProps> = ({navigation}) => {
screenType: VerificationScreenType.Phone,
});
} else if (otpStatusCode === 409) {
- Alert.alert(
- 'This phone number is already registered with us, please use another email.',
- );
+ Alert.alert(ERROR_EMAIL_IN_USE);
} else {
- Alert.alert(
- "Looks like Our phone servers might be down πŸ˜“'",
- "Try again in a couple minutes. We're sorry for the inconvenience.",
- );
+ Alert.alert(ERROR_SERVER_DOWN);
}
} else {
setForm({...form, attemptedSubmit: false});
diff --git a/src/screens/onboarding/RegistrationThree.tsx b/src/screens/onboarding/RegistrationThree.tsx
index 52a6de84..03348e6b 100644
--- a/src/screens/onboarding/RegistrationThree.tsx
+++ b/src/screens/onboarding/RegistrationThree.tsx
@@ -30,6 +30,11 @@ import {
import {passwordRegex, usernameRegex, REGISTER_ENDPOINT} from '../../constants';
import AsyncStorage from '@react-native-community/async-storage';
import {BackgroundGradientType} from '../../types';
+import {
+ ERROR_DOUBLE_CHECK_CONNECTION,
+ ERROR_REGISTRATION,
+ ERROR_SOMETHING_WENT_WRONG_REFRESH,
+} from '../../constants/strings';
type RegistrationScreenThreeRouteProp = RouteProp<
OnboardingStackParams,
@@ -189,12 +194,9 @@ const RegistrationThree: React.FC<RegistrationThreeProps> = ({
console.log(err);
}
} else if (statusCode === 409) {
- Alert.alert('Registration failed πŸ˜”', `${data}`);
+ Alert.alert(ERROR_REGISTRATION(data));
} 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);
}
} else {
Alert.alert(
@@ -207,10 +209,7 @@ const RegistrationThree: React.FC<RegistrationThreeProps> = ({
setTimeout(() => setForm({...form, attemptedSubmit: true}));
}
} catch (error) {
- Alert.alert(
- 'Registration failed πŸ˜“',
- 'Please double-check your network connection and retry.',
- );
+ Alert.alert(ERROR_REGISTRATION(ERROR_DOUBLE_CHECK_CONNECTION));
return {
name: 'Registration error',
description: error,
diff --git a/src/screens/onboarding/RegistrationTwo.tsx b/src/screens/onboarding/RegistrationTwo.tsx
index 2f67d8c8..707e621a 100644
--- a/src/screens/onboarding/RegistrationTwo.tsx
+++ b/src/screens/onboarding/RegistrationTwo.tsx
@@ -23,6 +23,7 @@ import {
import {nameRegex, emailRegex} from '../../constants';
import {BackgroundGradientType} from '../../types';
+import {ERROR_NEXT_PAGE} from '../../constants/strings';
type RegistrationScreenTwoRouteProp = RouteProp<
OnboardingStackParams,
@@ -143,10 +144,7 @@ const RegistrationTwo: React.FC<RegistrationTwoProps> = ({
setTimeout(() => setForm({...form, attemptedSubmit: true}));
}
} catch (error) {
- Alert.alert(
- 'There was a problem while loading the next page πŸ˜“',
- "Try again in a couple minutes. We're sorry for the inconvenience.",
- );
+ Alert.alert(ERROR_NEXT_PAGE);
return {
name: 'Navigation error',
description: error,
diff --git a/src/screens/onboarding/Verification.tsx b/src/screens/onboarding/Verification.tsx
index c808f30b..0fbe0d91 100644
--- a/src/screens/onboarding/Verification.tsx
+++ b/src/screens/onboarding/Verification.tsx
@@ -49,6 +49,10 @@ interface VerificationProps {
}
import {codeRegex} from '../../constants';
+import {
+ ERROR_INVALID_VERIFICATION_CODE_FORMAT,
+ ERROR_SOMETHING_WENT_WRONG,
+} from '../../constants/strings';
const Verification: React.FC<VerificationProps> = ({route, navigation}) => {
const [value, setValue] = React.useState('');
@@ -93,10 +97,10 @@ const Verification: React.FC<VerificationProps> = ({route, navigation}) => {
}
} catch (error) {
console.log(error);
- Alert.alert('Something went wrong');
+ Alert.alert(ERROR_SOMETHING_WENT_WRONG);
}
} else {
- Alert.alert('Please enter a valid 6 digit code');
+ Alert.alert(ERROR_INVALID_VERIFICATION_CODE_FORMAT);
}
};
@@ -115,7 +119,7 @@ const Verification: React.FC<VerificationProps> = ({route, navigation}) => {
}
} catch (error) {
console.log(error);
- Alert.alert('Something went wrong');
+ Alert.alert(ERROR_SOMETHING_WENT_WRONG);
}
};
diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx
index 5537d6bf..bc85d338 100644
--- a/src/screens/profile/CaptionScreen.tsx
+++ b/src/screens/profile/CaptionScreen.tsx
@@ -1,30 +1,27 @@
+import {RouteProp} from '@react-navigation/native';
+import {StackNavigationProp} from '@react-navigation/stack';
import React from 'react';
import {
- StyleSheet,
- View,
Image,
- Alert,
Keyboard,
- TouchableWithoutFeedback,
KeyboardAvoidingView,
Platform,
+ StyleSheet,
+ TouchableWithoutFeedback,
+ View,
} from 'react-native';
import {Button} from 'react-native-elements';
-import {SearchBackground, TaggBigInput} from '../../components';
-import {SCREEN_WIDTH, StatusBarHeight} from '../../utils';
-import AsyncStorage from '@react-native-community/async-storage';
-import {RouteProp} from '@react-navigation/native';
+import {useDispatch, useSelector} from 'react-redux';
import {MainStackParams} from 'src/routes';
-import {StackNavigationProp} from '@react-navigation/stack';
+import {SearchBackground, TaggBigInput} from '../../components';
import {CaptionScreenHeader} from '../../components/';
-import {MOMENTS_ENDPOINT} from '../../constants';
-import {useDispatch, useSelector} from 'react-redux';
+import {postMoment} from '../../services';
import {
loadUserMoments,
updateProfileCompletionStage,
} from '../../store/actions';
import {RootState} from '../../store/rootReducer';
-import {postMoment} from '../../services';
+import {SCREEN_WIDTH, StatusBarHeight} from '../../utils';
/**
* Upload Screen to allow users to upload posts to Tagg
diff --git a/src/screens/profile/EditProfile.tsx b/src/screens/profile/EditProfile.tsx
index a6849c7a..3fea14bf 100644
--- a/src/screens/profile/EditProfile.tsx
+++ b/src/screens/profile/EditProfile.tsx
@@ -40,6 +40,12 @@ import {RootState} from '../../store/rootReducer';
import {useDispatch, useSelector} from 'react-redux';
import {loadUserData} from '../../store/actions';
import {BackgroundGradientType} from '../../types';
+import {
+ ERROR_DOUBLE_CHECK_CONNECTION,
+ ERROR_SOMETHING_WENT_WRONG_REFRESH,
+ ERROR_UPLOAD_LARGE_PROFILE_PIC,
+ ERROR_UPLOAD_SMALL_PROFILE_PIC,
+} from '../../constants/strings';
type EditProfileNavigationProp = StackNavigationProp<
ProfileStackParams,
@@ -250,11 +256,11 @@ const EditProfile: React.FC<EditProfileProps> = ({route, navigation}) => {
const handleSubmit = useCallback(async () => {
if (!form.largePic) {
- Alert.alert('Please select a Header image!');
+ Alert.alert(ERROR_UPLOAD_LARGE_PROFILE_PIC);
return;
}
if (!form.smallPic) {
- Alert.alert('Please select a Profile Picture!');
+ Alert.alert(ERROR_UPLOAD_SMALL_PROFILE_PIC);
return;
}
if (!form.attemptedSubmit) {
@@ -355,13 +361,10 @@ const EditProfile: React.FC<EditProfileProps> = ({route, navigation}) => {
data.error || 'Something went wrong! 😭',
);
} 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('Please double-check your network connection and retry.');
+ Alert.alert(ERROR_DOUBLE_CHECK_CONNECTION);
return {
name: 'Profile creation error',
description: error,
diff --git a/src/services/BlockUserService.ts b/src/services/BlockUserService.ts
index 21e259b6..12ea0184 100644
--- a/src/services/BlockUserService.ts
+++ b/src/services/BlockUserService.ts
@@ -2,6 +2,7 @@
import {Alert} from 'react-native';
import {BLOCK_USER_ENDPOINT} from '../constants';
+import {ERROR_SOMETHING_WENT_WRONG_REFRESH} from '../constants/strings';
export const loadBlockedUsers = async (userId: string, token: string) => {
try {
@@ -44,18 +45,12 @@ export const blockOrUnblockUser = async (
return true;
} else {
console.log(await response.json());
- 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);
return false;
}
} catch (error) {
console.log(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);
return false;
}
};
@@ -77,18 +72,12 @@ export const isUserBlocked = async (
if (Math.floor(response.status / 100) === 2) {
const data = await response.json();
- return data['is_blocked'];
+ return data.is_blocked;
} else {
console.log(await response.json());
- 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(
- '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);
}
};
diff --git a/src/services/MomentCategoryService.ts b/src/services/MomentCategoryService.ts
index 57e64830..bb2c5542 100644
--- a/src/services/MomentCategoryService.ts
+++ b/src/services/MomentCategoryService.ts
@@ -1,5 +1,6 @@
import {Alert} from 'react-native';
import {MOMENT_CATEGORY_ENDPOINT} from '../constants';
+import {ERROR_CATEGORY_CREATION} from '../constants/strings';
export const loadMomentCategories: (
userId: string,
@@ -44,10 +45,10 @@ export const postMomentCategories: (
const status = response.status;
const data = await response.json();
if (status === 200) {
- return data['profile_completion_stage'];
+ return data.profile_completion_stage;
} else {
- Alert.alert('There was a problem updating categories!');
- console.log('Unable to update categories');
+ Alert.alert(ERROR_CATEGORY_CREATION);
+ console.log('Could not post categories!');
}
} catch (err) {
console.log(err);
diff --git a/src/services/MomentServices.ts b/src/services/MomentServices.ts
index 91ecf712..217b5857 100644
--- a/src/services/MomentServices.ts
+++ b/src/services/MomentServices.ts
@@ -1,6 +1,11 @@
import AsyncStorage from '@react-native-community/async-storage';
import {Alert} from 'react-native';
import {COMMENTS_ENDPOINT, MOMENTS_ENDPOINT} from '../constants';
+import {
+ ERROR_FAILED_TO_COMMENT,
+ ERROR_UPLOAD,
+ SUCCESS_PIC_UPLOAD,
+} from '../constants/strings';
import {MomentType} from '../types';
import {checkImageUploadStatus} from '../utils';
@@ -48,20 +53,12 @@ export const postMomentComment = async (
},
body: request,
});
- const status = response.status;
- if (status === 200) {
- const response_data = await response.json();
- return response_data;
- } else {
- Alert.alert('Something went wrong! 😭', 'Not able to post a comment');
- return {};
+ if (response.status !== 200) {
+ throw 'server error';
}
+ return await response.json();
} catch (error) {
- Alert.alert(
- 'Something went wrong! 😭',
- 'Not able to post a comment',
- error,
- );
+ Alert.alert(ERROR_FAILED_TO_COMMENT);
return {};
}
};
@@ -136,15 +133,15 @@ export const postMoment: (
});
let statusCode = response.status;
let data = await response.json();
- if (statusCode === 200 && checkImageUploadStatus(data['moments'])) {
- Alert.alert('The picture was uploaded successfully!');
- return data['profile_completion_stage'];
+ if (statusCode === 200 && checkImageUploadStatus(data.moments)) {
+ Alert.alert(SUCCESS_PIC_UPLOAD);
+ return data.profile_completion_stage;
} else {
- Alert.alert('An error occured while uploading. Please try again!');
+ Alert.alert(ERROR_UPLOAD);
}
} catch (err) {
console.log(err);
- Alert.alert('An error occured during authenticaion. Please login again!');
+ Alert.alert(ERROR_UPLOAD);
}
return undefined;
};
diff --git a/src/services/ReportingService.ts b/src/services/ReportingService.ts
index 1563d086..8c0a4bfb 100644
--- a/src/services/ReportingService.ts
+++ b/src/services/ReportingService.ts
@@ -3,6 +3,10 @@
import {REPORT_ISSUE_ENDPOINT} from '../constants';
import {Alert} from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
+import {
+ ERROR_SOMETHING_WENT_WRONG,
+ MARKED_AS_MSG,
+} from '../constants/strings';
export const sendReport = async (
moment_id: string,
@@ -25,15 +29,15 @@ export const sendReport = async (
let statusCode = response.status;
if (statusCode === 200) {
- Alert.alert('Marked as ' + message.split(' ')[2]);
+ Alert.alert(MARKED_AS_MSG(message.split(' ')[2]));
} else {
- Alert.alert('Something went wrong!', 'Please try again.');
+ Alert.alert(ERROR_SOMETHING_WENT_WRONG);
}
if (callback) {
callback();
}
} catch (error) {
- Alert.alert('Something went wrong!', 'Please try again.');
+ Alert.alert(ERROR_SOMETHING_WENT_WRONG);
console.log(
'Something went wrong! 😭',
'Unable able to retrieve data',
diff --git a/src/services/SocialLinkingService.ts b/src/services/SocialLinkingService.ts
index 4a01ee50..1423c8c0 100644
--- a/src/services/SocialLinkingService.ts
+++ b/src/services/SocialLinkingService.ts
@@ -12,6 +12,8 @@ import {
LINK_TWITTER_ENDPOINT,
LINK_TWITTER_OAUTH,
} from '../constants';
+import {COMING_SOON_MSG, ERROR_LINK, SUCCESS_LINK} from '../constants/strings';
+import {CategorySelection} from '../screens';
// A list of endpoint strings for all the integrated socials
export const integratedEndpoints: {[social: string]: [string, string]} = {
@@ -124,7 +126,7 @@ export const handlePressForAuthBrowser: (
) => Promise<boolean> = async (socialType: string) => {
try {
if (!(socialType in integratedEndpoints)) {
- Alert.alert('Coming soon!');
+ Alert.alert(COMING_SOON_MSG);
return false;
}
@@ -168,7 +170,7 @@ export const handlePressForAuthBrowser: (
if (!success) {
throw 'Unable to register with backend';
}
- Alert.alert(`Successfully linked ${socialType} πŸŽ‰`);
+ Alert.alert(SUCCESS_LINK(socialType));
return true;
} else if (response.type === 'cancel') {
return false;
@@ -178,14 +180,12 @@ export const handlePressForAuthBrowser: (
})
.catch((error) => {
console.log(error);
- Alert.alert(
- `Something went wrong, we can't link with ${socialType} πŸ˜”`,
- );
+ Alert.alert(ERROR_LINK(socialType));
return false;
});
} catch (error) {
console.log(error);
- Alert.alert(`Something went wrong, we can't link with ${socialType} πŸ˜”`);
+ Alert.alert(ERROR_LINK(socialType));
}
return false;
};
diff --git a/src/services/UserFriendsServices.ts b/src/services/UserFriendsServices.ts
index 0b138fc3..f7a39abf 100644
--- a/src/services/UserFriendsServices.ts
+++ b/src/services/UserFriendsServices.ts
@@ -2,6 +2,7 @@
import {Alert} from 'react-native';
import {FRIENDS_ENDPOINT} from '../constants';
+import {ERROR_SOMETHING_WENT_WRONG_REFRESH} from '../constants/strings';
export const loadFriends = async (userId: string, token: string) => {
try {
@@ -46,18 +47,12 @@ export const friendOrUnfriendUser = async (
return true;
} else {
console.log(await response.json());
- 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);
return false;
}
} catch (error) {
console.log(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);
return false;
}
};
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) {