From 962273b9970175508023a9a6c834030d822b5f03 Mon Sep 17 00:00:00 2001 From: George Rusu Date: Sat, 8 May 2021 00:07:37 -0700 Subject: updated header text on password step --- src/screens/onboarding/BasicInfoOnboarding.tsx | 98 ++++++++++++-------------- 1 file changed, 46 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/screens/onboarding/BasicInfoOnboarding.tsx b/src/screens/onboarding/BasicInfoOnboarding.tsx index 3fa33f63..1e3522bd 100644 --- a/src/screens/onboarding/BasicInfoOnboarding.tsx +++ b/src/screens/onboarding/BasicInfoOnboarding.tsx @@ -443,58 +443,52 @@ const BasicInfoOnboarding: React.FC = ({route}) => { ) : ( - - - setPassVisibility(!passVisibility)}> - Show Password - - - - - - - + <>SIGN UP + + + setPassVisibility(!passVisibility)}> + Show Password + + + + + + + )} )} -- cgit v1.2.3-70-g09d2 From 51d940e5d90d1f3ef0e94eeeb065a681d68d4973 Mon Sep 17 00:00:00 2001 From: George Rusu Date: Mon, 10 May 2021 11:14:56 -0700 Subject: previous onboarding steps display submitted entries --- src/screens/onboarding/BasicInfoOnboarding.tsx | 111 ++++++++++++++----------- 1 file changed, 64 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/screens/onboarding/BasicInfoOnboarding.tsx b/src/screens/onboarding/BasicInfoOnboarding.tsx index 1e3522bd..8ddb74e1 100644 --- a/src/screens/onboarding/BasicInfoOnboarding.tsx +++ b/src/screens/onboarding/BasicInfoOnboarding.tsx @@ -208,31 +208,38 @@ const BasicInfoOnboarding: React.FC = ({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 }, { placeholder: 'Last Name', onChangeText: (text) => handleNameUpdate(text, 1), + value: form.lname }, { placeholder: 'Phone', onChangeText: handlePhoneUpdate, + value: form.phone }, { placeholder: 'School Email', onChangeText: handleEmailUpdate, + value: form.email }, { placeholder: 'Username', onChangeText: (text) => handleNameUpdate(text, 2), + value: form.username }, { placeholder: 'Password', onChangeText: handlePasswordUpdate, + value: form.password }, ]; const resetForm = (formStep: String) => { @@ -421,6 +428,7 @@ const BasicInfoOnboarding: React.FC = ({route}) => { returnKeyType="done" selectionColor="white" onChangeText={step.onChangeText} + value={step.value} onSubmitEditing={advance} autoFocus={true} blurOnSubmit={false} @@ -443,52 +451,61 @@ const BasicInfoOnboarding: React.FC = ({route}) => { ) : ( - <>SIGN UP - - - setPassVisibility(!passVisibility)}> - Show Password - - - - - - - + <> + SIGN UP + + + setPassVisibility(!passVisibility)}> + Show Password + + + + + + + + )} )} -- cgit v1.2.3-70-g09d2 From 4859c58b1d6bebc7f8a1b4e7345393a1dfdc33d8 Mon Sep 17 00:00:00 2001 From: George Rusu Date: Mon, 10 May 2021 16:06:41 -0700 Subject: updating state to check taken email/usernames --- src/constants/api.ts | 1 + src/screens/onboarding/BasicInfoOnboarding.tsx | 29 +++++++++++++++++++++++--- src/services/UserProfileService.ts | 27 ++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/constants/api.ts b/src/constants/api.ts index 45b6e8ae..53392fb5 100644 --- a/src/constants/api.ts +++ b/src/constants/api.ts @@ -12,6 +12,7 @@ const API_URL: string = BASE_URL + 'api/'; export const LOGIN_ENDPOINT: string = API_URL + 'login/'; export const VERSION_ENDPOINT: string = API_URL + 'version/v2/'; export const REGISTER_ENDPOINT: string = API_URL + 'register/'; +export const REGISTER_VALIDATE_ENDPOINT: string = API_URL + 'register/validate/'; export const EDIT_PROFILE_ENDPOINT: string = API_URL + 'edit-profile/'; export const SEND_OTP_ENDPOINT: string = API_URL + 'send-otp/'; export const VERIFY_OTP_ENDPOINT: string = API_URL + 'verify-otp/'; diff --git a/src/screens/onboarding/BasicInfoOnboarding.tsx b/src/screens/onboarding/BasicInfoOnboarding.tsx index 8ddb74e1..2bfe449c 100644 --- a/src/screens/onboarding/BasicInfoOnboarding.tsx +++ b/src/screens/onboarding/BasicInfoOnboarding.tsx @@ -2,6 +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 React, {useEffect, useState} from 'react'; import { Alert, @@ -38,7 +39,7 @@ import { ERROR_T_AND_C_NOT_ACCEPTED, } from '../../constants/strings'; import {OnboardingStackParams} from '../../routes'; -import {sendOtpStatusCode, sendRegister} from '../../services'; +import {sendOtpStatusCode, sendRegister, verifyExistingInformation} from '../../services'; import {BackgroundGradientType} from '../../types'; import {HeaderHeight, SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; @@ -63,12 +64,18 @@ const BasicInfoOnboarding: React.FC = ({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 [autoCapitalize, setAutoCap] = useState< 'none' | 'sentences' | 'words' | 'characters' | undefined >('none'); const [fadeValue, setFadeValue] = useState>( new Animated.Value(0), ); + useEffect(() => { + console.log(invalidWithError) + setValid(false); + }, [invalidWithError]) + const fadeButtonValue = useValue(0); const [form, setForm] = useState({ fname: '', @@ -91,6 +98,7 @@ const BasicInfoOnboarding: React.FC = ({route}) => { }).start(); }; + useEffect(() => { const fade = async () => { Animated.timing(fadeValue, { @@ -284,9 +292,24 @@ const BasicInfoOnboarding: React.FC = ({route}) => { } }; const step = formSteps[currentStep]; - const advance = () => { + useEffect(() => { + if(step.placeholder!== 'School Email') { + setInvalidWithError("Please enter a valid " + step.placeholder.toLowerCase()) + } + }, [step]) + 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") + return; + } + } + console.log('shouldnt happen') + console.log("stepL: " + step.placeholder) setCurrentStep(currentStep + 1); setAttemptedSubmit(false); setValid(false); @@ -436,7 +459,7 @@ const BasicInfoOnboarding: React.FC = ({route}) => { warning: styles.passWarning, }} valid={valid} - invalidWarning={`Please enter a valid ${step.placeholder.toLowerCase()}`} + invalidWarning={invalidWithError} attemptedSubmit={attemptedSubmit} /> diff --git a/src/services/UserProfileService.ts b/src/services/UserProfileService.ts index c11d874f..8b7b78e1 100644 --- a/src/services/UserProfileService.ts +++ b/src/services/UserProfileService.ts @@ -11,6 +11,7 @@ import { PROFILE_INFO_ENDPOINT, PROFILE_PHOTO_ENDPOINT, REGISTER_ENDPOINT, + REGISTER_VALIDATE_ENDPOINT, SEND_OTP_ENDPOINT, TAGG_CUSTOMER_SUPPORT, USER_PROFILE_ENDPOINT, @@ -432,3 +433,29 @@ export const visitedUserProfile = async (userId: string) => { return undefined; } }; + +export const verifyExistingInformation = async ( + email: string | undefined, + username: string | undefined, +) => { + try { + const form = new FormData(); + if (email) { + form.append('email', email); + } + if (username) { + form.append('username', username); + } + const response = await fetch(REGISTER_VALIDATE_ENDPOINT, { + method: 'POST', + headers: { + 'Content-Type': 'multipart/form-data', + }, + body: form, + }); + return response.status===200; + } catch (error) { + console.log(error); + return false; + } +}; -- cgit v1.2.3-70-g09d2 From 86a24044fd61a42f4da7cf75d0180870e95704b9 Mon Sep 17 00:00:00 2001 From: George Rusu Date: Mon, 10 May 2021 16:27:21 -0700 Subject: removed unused imports. added taken username request --- src/screens/onboarding/BasicInfoOnboarding.tsx | 62 +++++++++++++++--------- src/screens/onboarding/ProfileInfoOnboarding.tsx | 2 +- 2 files changed, 39 insertions(+), 25 deletions(-) (limited to 'src') 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 = ({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>( new Animated.Value(0), ); + useEffect(() => { - console.log(invalidWithError) setValid(false); - }, [invalidWithError]) + }, [invalidWithError]); const fadeButtonValue = useValue(0); const [form, setForm] = useState({ @@ -98,7 +104,6 @@ const BasicInfoOnboarding: React.FC = ({route}) => { }).start(); }; - useEffect(() => { const fade = async () => { Animated.timing(fadeValue, { @@ -216,38 +221,38 @@ const BasicInfoOnboarding: React.FC = ({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 = ({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, -- cgit v1.2.3-70-g09d2 From 44cdf64cd2c0376cd203a352b344ebeb56a06c49 Mon Sep 17 00:00:00 2001 From: grusuTagg <83606116+grusuTagg@users.noreply.github.com> Date: Mon, 10 May 2021 17:09:43 -0700 Subject: Deleted unused import --- src/screens/onboarding/BasicInfoOnboarding.tsx | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/screens/onboarding/BasicInfoOnboarding.tsx b/src/screens/onboarding/BasicInfoOnboarding.tsx index 77aa8ea1..3058a04e 100644 --- a/src/screens/onboarding/BasicInfoOnboarding.tsx +++ b/src/screens/onboarding/BasicInfoOnboarding.tsx @@ -2,7 +2,6 @@ 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 React, {useEffect, useState} from 'react'; import { Alert, -- cgit v1.2.3-70-g09d2 From 14c4ec9f5350c11b263e3e84b6f5298cb592de9b Mon Sep 17 00:00:00 2001 From: grusuTagg <83606116+grusuTagg@users.noreply.github.com> Date: Mon, 10 May 2021 17:10:09 -0700 Subject: Update ProfileInfoOnboarding.tsx --- src/screens/onboarding/ProfileInfoOnboarding.tsx | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/screens/onboarding/ProfileInfoOnboarding.tsx b/src/screens/onboarding/ProfileInfoOnboarding.tsx index 13cffd10..cdfbea8f 100644 --- a/src/screens/onboarding/ProfileInfoOnboarding.tsx +++ b/src/screens/onboarding/ProfileInfoOnboarding.tsx @@ -16,7 +16,6 @@ import Animated from 'react-native-reanimated'; import { Background, BirthDatePicker, - // RegistrationWizard, TaggDropDown, TaggInput, UniversitySelection, -- cgit v1.2.3-70-g09d2