aboutsummaryrefslogtreecommitdiff
path: root/src/screens/onboarding/Login.tsx
diff options
context:
space:
mode:
authorIvan Chen <ivan@thetaggid.com>2021-02-26 22:27:42 -0500
committerGitHub <noreply@github.com>2021-02-26 22:27:42 -0500
commita7b4f16c71ce65f9be9ec1399eceacbe6f5329b8 (patch)
treedb95880032b6f6149ecff5d12c3270265e003d33 /src/screens/onboarding/Login.tsx
parent8b862e92fb90c0bbf95a77348632df9b42b02722 (diff)
parent7faeb487da4fac1e57d8d147da1e41cac16bb28d (diff)
Merge pull request #269 from IvanIFChen/tma656-revamp-onboarding
[TMA-656] Revamp Onboarding
Diffstat (limited to 'src/screens/onboarding/Login.tsx')
-rw-r--r--src/screens/onboarding/Login.tsx15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/screens/onboarding/Login.tsx b/src/screens/onboarding/Login.tsx
index 450c5039..2ca4172b 100644
--- a/src/screens/onboarding/Login.tsx
+++ b/src/screens/onboarding/Login.tsx
@@ -1,7 +1,7 @@
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 React, {useEffect, useRef} from 'react';
import {
Alert,
Image,
@@ -21,12 +21,13 @@ import {
ERROR_FAILED_LOGIN_INFO,
ERROR_INVALID_LOGIN,
ERROR_LOGIN_FAILED,
+ ERROR_NOT_ONBOARDED,
ERROR_SOMETHING_WENT_WRONG_REFRESH,
} from '../../constants/strings';
import {OnboardingStackParams} from '../../routes/onboarding';
import {fcmService} from '../../services';
import {RootState} from '../../store/rootReducer';
-import {BackgroundGradientType, UserType} from '../../types';
+import {BackgroundGradientType} from '../../types';
import {normalize, userLogin} from '../../utils';
import UpdateRequired from './UpdateRequired';
@@ -155,7 +156,7 @@ const Login: React.FC<LoginProps> = ({navigation}: LoginProps) => {
let statusCode = response.status;
let data = await response.json();
- if (statusCode === 200) {
+ if (statusCode === 200 && data.isOnboarded) {
//Stores token received in the response into client's AsynStorage
try {
await AsyncStorage.setItem('token', data.token);
@@ -167,6 +168,13 @@ const Login: React.FC<LoginProps> = ({navigation}: LoginProps) => {
console.log(data);
Alert.alert(ERROR_INVALID_LOGIN);
}
+ } else if (statusCode === 200 && !data.isOnboarded) {
+ navigation.navigate('InvitationCodeVerification', {
+ userId: data.UserID,
+ });
+ setTimeout(() => {
+ Alert.alert(ERROR_NOT_ONBOARDED);
+ }, 500);
} else if (statusCode === 401) {
Alert.alert(ERROR_FAILED_LOGIN_INFO);
} else {
@@ -192,7 +200,6 @@ const Login: React.FC<LoginProps> = ({navigation}: LoginProps) => {
navigation.navigate('WelcomeScreen');
setForm({...form, attemptedSubmit: false});
};
-
/**
* Login screen forgot password button.
*/