diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/screens/onboarding/BasicInfoOnboarding.tsx | 62 | ||||
-rw-r--r-- | src/screens/onboarding/ProfileInfoOnboarding.tsx | 2 |
2 files changed, 39 insertions, 25 deletions
diff --git a/src/screens/onboarding/BasicInfoOnboarding.tsx b/src/screens/onboarding/BasicInfoOnboarding.tsx index 2bfe449c..77aa8ea1 100644 --- a/src/screens/onboarding/BasicInfoOnboarding.tsx +++ b/src/screens/onboarding/BasicInfoOnboarding.tsx @@ -2,7 +2,7 @@ import AsyncStorage from '@react-native-community/async-storage'; import {useNavigation} from '@react-navigation/core'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; -import { invalid } from 'moment'; +// import {invalid} from 'moment'; import React, {useEffect, useState} from 'react'; import { Alert, @@ -39,7 +39,11 @@ import { ERROR_T_AND_C_NOT_ACCEPTED, } from '../../constants/strings'; import {OnboardingStackParams} from '../../routes'; -import {sendOtpStatusCode, sendRegister, verifyExistingInformation} from '../../services'; +import { + sendOtpStatusCode, + sendRegister, + verifyExistingInformation, +} from '../../services'; import {BackgroundGradientType} from '../../types'; import {HeaderHeight, SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; @@ -64,17 +68,19 @@ const BasicInfoOnboarding: React.FC<BasicInfoOnboardingProps> = ({route}) => { const [currentStep, setCurrentStep] = useState(0); const [tcAccepted, setTCAccepted] = useState(false); const [passVisibility, setPassVisibility] = useState(false); - const [invalidWithError, setInvalidWithError] = useState("Please enter a valid ") + const [invalidWithError, setInvalidWithError] = useState( + 'Please enter a valid ', + ); const [autoCapitalize, setAutoCap] = useState< 'none' | 'sentences' | 'words' | 'characters' | undefined >('none'); const [fadeValue, setFadeValue] = useState<Animated.Value<number>>( new Animated.Value(0), ); + useEffect(() => { - console.log(invalidWithError) setValid(false); - }, [invalidWithError]) + }, [invalidWithError]); const fadeButtonValue = useValue<number>(0); const [form, setForm] = useState({ @@ -98,7 +104,6 @@ const BasicInfoOnboarding: React.FC<BasicInfoOnboardingProps> = ({route}) => { }).start(); }; - useEffect(() => { const fade = async () => { Animated.timing(fadeValue, { @@ -216,38 +221,38 @@ const BasicInfoOnboarding: React.FC<BasicInfoOnboardingProps> = ({route}) => { }; const formSteps: { placeholder: string; - onChangeText: (text: string) => void; + onChangeText: (text: string) => void; value: string; }[] = [ { placeholder: 'First Name', onChangeText: (text) => handleNameUpdate(text, 0), - value: form.fname + value: form.fname, }, { placeholder: 'Last Name', onChangeText: (text) => handleNameUpdate(text, 1), - value: form.lname + value: form.lname, }, { placeholder: 'Phone', onChangeText: handlePhoneUpdate, - value: form.phone + value: form.phone, }, { placeholder: 'School Email', onChangeText: handleEmailUpdate, - value: form.email + value: form.email, }, { placeholder: 'Username', onChangeText: (text) => handleNameUpdate(text, 2), - value: form.username + value: form.username, }, { placeholder: 'Password', onChangeText: handlePasswordUpdate, - value: form.password + value: form.password, }, ]; const resetForm = (formStep: String) => { @@ -293,23 +298,32 @@ const BasicInfoOnboarding: React.FC<BasicInfoOnboardingProps> = ({route}) => { }; const step = formSteps[currentStep]; useEffect(() => { - if(step.placeholder!== 'School Email') { - setInvalidWithError("Please enter a valid " + step.placeholder.toLowerCase()) - } - }, [step]) - const advance = async() => { + setInvalidWithError( + 'Please enter a valid ' + step.placeholder.toLowerCase(), + ); + }, [currentStep]); + const advance = async () => { setAttemptedSubmit(true); if (valid) { if (step.placeholder === 'School Email') { - const verifiedInfo = await verifyExistingInformation(form.email, undefined); - if(!verifiedInfo) { - console.log("here"); - setInvalidWithError("Email is taken") + const verifiedInfo = await verifyExistingInformation( + form.email, + undefined, + ); + if (!verifiedInfo) { + setInvalidWithError('Email is taken'); + return; + } + } else if (step.placeholder === 'Username') { + const verifiedInfo = await verifyExistingInformation( + undefined, + form.username, + ); + if (!verifiedInfo) { + setInvalidWithError('Username is taken'); return; } } - console.log('shouldnt happen') - console.log("stepL: " + step.placeholder) setCurrentStep(currentStep + 1); setAttemptedSubmit(false); setValid(false); diff --git a/src/screens/onboarding/ProfileInfoOnboarding.tsx b/src/screens/onboarding/ProfileInfoOnboarding.tsx index a481b0c0..13cffd10 100644 --- a/src/screens/onboarding/ProfileInfoOnboarding.tsx +++ b/src/screens/onboarding/ProfileInfoOnboarding.tsx @@ -16,7 +16,7 @@ import Animated from 'react-native-reanimated'; import { Background, BirthDatePicker, - RegistrationWizard, + // RegistrationWizard, TaggDropDown, TaggInput, UniversitySelection, |