aboutsummaryrefslogtreecommitdiff
path: root/src/screens/onboarding/Login.tsx
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/screens/onboarding/Login.tsx
parent1dccfb1d3e9470d81de8d1ec0a0dbb3803372f7d (diff)
created strings.ts and linting
Diffstat (limited to 'src/screens/onboarding/Login.tsx')
-rw-r--r--src/screens/onboarding/Login.tsx50
1 files changed, 24 insertions, 26 deletions
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,