diff options
author | Ivan Chen <ivan@tagg.id> | 2021-03-19 13:25:44 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-03-19 13:25:44 -0400 |
commit | e207b2bd73a18a3602ef3f2ef707f8d8fd889903 (patch) | |
tree | f336bc1cafa8af3fbbca6afa22b4a00c990d4f1f /src | |
parent | 853b92cce77bd84fd93806b6519afa4ac4dde508 (diff) |
changed alert text, login works
Diffstat (limited to 'src')
-rw-r--r-- | src/constants/strings.ts | 2 | ||||
-rw-r--r-- | src/routes/onboarding/OnboardingStackNavigator.tsx | 2 | ||||
-rw-r--r-- | src/screens/onboarding/InvitationCodeVerification.tsx | 11 | ||||
-rw-r--r-- | src/screens/onboarding/Login.tsx | 1 | ||||
-rw-r--r-- | src/screens/onboarding/OnboardingStepThree.tsx | 4 |
5 files changed, 14 insertions, 6 deletions
diff --git a/src/constants/strings.ts b/src/constants/strings.ts index f289cfc1..cb442b7b 100644 --- a/src/constants/strings.ts +++ b/src/constants/strings.ts @@ -55,7 +55,7 @@ export const MOMENT_DELETED_MSG = 'Moment deleted....Some moments have to go, to export const NO_NEW_NOTIFICATIONS = 'You have no new notifications'; export const NO_RESULTS_FOUND = 'No Results Found!'; export const SUCCESS_CATEGORY_DELETE = 'Category successfully deleted, but its memory will live on'; -export const SUCCESS_INVITATION_CODE = 'Perfect! You entered a valid invitation code, you are now able to login and explore Tagg!'; +export const SUCCESS_INVITATION_CODE = 'Welcome to Tagg!'; export const SUCCESS_LINK = (str: string) => `Successfully linked ${str} 🎉`; export const SUCCESS_PIC_UPLOAD = 'Beautiful, the picture was uploaded successfully!'; export const SUCCESS_BADGES_UPDATE = 'Badges updated successfully!' diff --git a/src/routes/onboarding/OnboardingStackNavigator.tsx b/src/routes/onboarding/OnboardingStackNavigator.tsx index 0cdeecdf..a51a6c86 100644 --- a/src/routes/onboarding/OnboardingStackNavigator.tsx +++ b/src/routes/onboarding/OnboardingStackNavigator.tsx @@ -35,7 +35,7 @@ export type OnboardingStackParams = { PhoneVerification: {firstName: string; lastName: string; phone: string}; OnboardingStepTwo: {firstName: string; lastName: string; phone: string}; OnboardingStepThree: {userId: string; username: string}; - InvitationCodeVerification: {userId: string}; + InvitationCodeVerification: {userId: string; username: string}; }; export const OnboardingStack = createStackNavigator<OnboardingStackParams>(); diff --git a/src/screens/onboarding/InvitationCodeVerification.tsx b/src/screens/onboarding/InvitationCodeVerification.tsx index 41d17f29..c8ef16df 100644 --- a/src/screens/onboarding/InvitationCodeVerification.tsx +++ b/src/screens/onboarding/InvitationCodeVerification.tsx @@ -1,3 +1,4 @@ +import AsyncStorage from '@react-native-community/async-storage'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; import React from 'react'; @@ -9,6 +10,7 @@ import { useBlurOnFulfill, useClearByFocusCell, } from 'react-native-confirmation-code-field'; +import {useDispatch} from 'react-redux'; import { ArrowButton, Background, @@ -25,7 +27,7 @@ import { } from '../../constants/strings'; import {OnboardingStackParams} from '../../routes'; import {BackgroundGradientType} from '../../types'; -import {SCREEN_WIDTH} from '../../utils'; +import {SCREEN_WIDTH, userLogin} from '../../utils'; type InvitationCodeVerificationRouteProp = RouteProp< OnboardingStackParams, @@ -56,6 +58,7 @@ const InvitationCodeVerification: React.FC<InvitationCodeVerificationProps> = ({ value, setValue, }); + const dispatch = useDispatch(); const handleInvitationCodeVerification = async () => { if (value.length === 6) { @@ -71,7 +74,11 @@ const InvitationCodeVerification: React.FC<InvitationCodeVerificationProps> = ({ ); if (verifyInviteCodeResponse.status === 200) { - navigation.navigate('Login'); + const userId = route.params.userId; + const username = route.params.username; + await AsyncStorage.setItem('userId', userId); + await AsyncStorage.setItem('username', username); + userLogin(dispatch, {userId, username}); setTimeout(() => { Alert.alert(SUCCESS_INVITATION_CODE); }, 500); diff --git a/src/screens/onboarding/Login.tsx b/src/screens/onboarding/Login.tsx index cfa39dbd..6d9d3a97 100644 --- a/src/screens/onboarding/Login.tsx +++ b/src/screens/onboarding/Login.tsx @@ -170,6 +170,7 @@ const Login: React.FC<LoginProps> = ({navigation}: LoginProps) => { } else if (statusCode === 200 && !data.isOnboarded) { navigation.navigate('InvitationCodeVerification', { userId: data.UserID, + username: username, }); setTimeout(() => { Alert.alert(ERROR_NOT_ONBOARDED); diff --git a/src/screens/onboarding/OnboardingStepThree.tsx b/src/screens/onboarding/OnboardingStepThree.tsx index 64a2a2f7..f22d720f 100644 --- a/src/screens/onboarding/OnboardingStepThree.tsx +++ b/src/screens/onboarding/OnboardingStepThree.tsx @@ -57,7 +57,7 @@ const OnboardingStepThree: React.FC<OnboardingStepThreeProps> = ({ route, navigation, }) => { - const {userId} = route.params; + const {userId, username} = route.params; let emptyDate: string | undefined; const [form, setForm] = React.useState({ smallPic: '', @@ -224,12 +224,12 @@ const OnboardingStepThree: React.FC<OnboardingStepThreeProps> = ({ }, body: request, }); - console.log(route.params.userId); let statusCode = response.status; let data = await response.json(); if (statusCode === 200) { navigation.navigate('InvitationCodeVerification', { userId: route.params.userId, + username: username, }); } else if (statusCode === 400) { Alert.alert( |