diff options
author | Ivan Chen <ivan@tagg.id> | 2021-01-11 16:11:11 -0500 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-01-15 14:19:50 -0500 |
commit | 080e76350c2570eeb096fad40fe95f1b766b4539 (patch) | |
tree | bcb9f73f2c192f8c34f2064a5c3fd003756c2823 /src/screens | |
parent | 1dccfb1d3e9470d81de8d1ec0a0dbb3803372f7d (diff) |
created strings.ts and linting
Diffstat (limited to 'src/screens')
-rw-r--r-- | src/screens/onboarding/CategorySelection.tsx | 5 | ||||
-rw-r--r-- | src/screens/onboarding/InvitationCodeVerification.tsx | 17 | ||||
-rw-r--r-- | src/screens/onboarding/Login.tsx | 50 | ||||
-rw-r--r-- | src/screens/onboarding/ProfileOnboarding.tsx | 24 | ||||
-rw-r--r-- | src/screens/onboarding/RegistrationOne.tsx | 10 | ||||
-rw-r--r-- | src/screens/onboarding/RegistrationThree.tsx | 17 | ||||
-rw-r--r-- | src/screens/onboarding/RegistrationTwo.tsx | 6 | ||||
-rw-r--r-- | src/screens/onboarding/Verification.tsx | 10 | ||||
-rw-r--r-- | src/screens/profile/CaptionScreen.tsx | 21 | ||||
-rw-r--r-- | src/screens/profile/EditProfile.tsx | 17 |
10 files changed, 89 insertions, 88 deletions
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..875523d3 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, +} 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, 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..d0a63a23 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, + 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, 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, |