Skip to content

Commit

Permalink
Merge pull request #114 from ctcusc/lb-updatereg
Browse files Browse the repository at this point in the history
Spring 8 - update registration
  • Loading branch information
lynnebai authored Apr 9, 2020
2 parents 9fb828d + 799de17 commit 21c5f40
Show file tree
Hide file tree
Showing 8 changed files with 1,669 additions and 1,545 deletions.
Binary file added assets/images/registergraphic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ export default function CreatePasswordScreen(props: Props) {
const [confirmPassword, setConfirmPassword] = useState('')
const {navigate} = props.navigation
const user = {
userTitle: props.navigation .state.params.userTitle,
companyCode: props.navigation .state.params.companyCode,
name: props.navigation .state.params.name,
email: props.navigation .state.params.email
email: props.navigation .state.params.email,
userRecord: props.navigation .state.params.userRecord,
}
const message = 'Keep this secure! Use 8+ characters'

async function handleRegister(){
fetch(`${BASE_PATH}/api/auth/register`, {
Expand All @@ -35,21 +36,15 @@ export default function CreatePasswordScreen(props: Props) {
'Content-Type': 'application/json',
},
body: JSON.stringify({
'Full Name': user.name,
'Email': user.email,
'Current Title': user.userTitle,
'Company Code': user.companyCode,
'Password': password,
'_record': user.userRecord,
}),
})
.then(res => res.json())
.then(data => {
console.log(data)
if(data.ID == undefined) {
Alert.alert('User already exists')
} else {
navigate('Onboarding')
}
navigate('Onboarding')
})
.catch(error => {
console.log('Error: ' + error)
Expand All @@ -60,7 +55,8 @@ export default function CreatePasswordScreen(props: Props) {
<View style={styles.container}>
<View style={styles.main}>
<BlackHeading title="Create a Password" />
<Text style={styles.regularText}>Keep this secure!</Text>
<Text style={styles.regularText}>{message}</Text>
<Text style={styles.margin}></Text>
<GreyTextInput changeTextContent={(password) => {
setPassword(password)
}} placeholder="Password (8+ characters)" inputType='password' input={password}/>
Expand Down
18 changes: 18 additions & 0 deletions src/screens/Auth/RegisterStack/CreatePasswordScreen/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const styles = StyleSheet.create({
color: '#000',
},

margin: {
marginBottom: '10%',
},

regularText: {
fontSize: 16,
fontFamily: 'roboto-regular',
Expand Down Expand Up @@ -52,6 +56,20 @@ const styles = StyleSheet.create({
marginTop: '4%'
},

messageError: {
fontSize: 16,
fontFamily: 'roboto-regular',
fontStyle: 'normal',
lineHeight: 19,
textAlign: 'center',
color: '#777777',
marginLeft: '17.6%',
marginRight: '17.3%',
marginTop: '7%',
marginBottom: '7.7%',
color: 'red',
},

imageLine: {
marginTop: '2%',
flexDirection: 'row',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,67 @@ import React, { useState } from 'react'
import {
Text,
View,
Alert,
Image,
TouchableOpacity,
} from 'react-native'
import styles from './styles'
import BlackHeading from '../../../../shared_components/BlackHeading/BlackHeading'
import GreyTextInput from '../../../../shared_components/GreyTextInput/GreyTextInput'
import PinkButton from '../../../../shared_components/PinkButton/PinkButton'
import { NavigationScreenProp, NavigationState } from 'react-navigation'
import { BASE_PATH } from 'react-native-dotenv'

interface Props {
navigation: NavigationScreenProp<NavigationState>,
}

export default function GetStartedScreen(props: Props) {
const [title, setTitle] = useState('')
const [code, setCode] = useState('')
const {navigate} = props.navigation
const [message, setMessage] = useState('It\'s a 9-character code provided by Gladeo!')
const [messageStyle, setMessageStyle] = useState(styles.messageNormal)

async function checkCompanyCode(){
fetch(`${BASE_PATH}/api/company/${code}`, {
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
})
.then(res => res.json())
.then(data => {
console.log(data)
if(data.statusCode == 404) {
setMessage('Error: Company code is not valid.')
setMessageStyle(styles.messageError)
setCode('')
} else if(data.statusCode == 409) {
setMessage('Error: User with code '+code+' is already registered.')
setMessageStyle(styles.messageError)
setCode('')
} else {
navigate('Register', {
companyCode: code,
userRecord: data['_record']
})
}
})
.catch(error => {
console.log('Error: ' + error)
})
}

return (
<View style={styles.container}>
<View style={styles.main}>
<BlackHeading title="Let's get Started!" />
<Text style={styles.margin}></Text>
<GreyTextInput changeTextContent={(title) => setTitle(title)} placeholder="Current Title" inputType='text' input={title}/>
<Text style={messageStyle}>{message}</Text>
<Image style={styles.graphic} resizeMode='contain' source={require('../../../../../assets/images/registergraphic.png')} />
<GreyTextInput changeTextContent={(code) => setCode(code)} placeholder="Company Code" inputType='text' input={code}/>
<PinkButton title="START CREATING"
onPress={
() => navigate('Register', {
userTitle: title,
companyCode: code,
})
}
disabled={!title || !code}
onPress={checkCompanyCode}
disabled={!code}
/>
</View>

Expand Down
19 changes: 13 additions & 6 deletions src/screens/Auth/RegisterStack/GetStartedScreen/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
paddingTop: '40%',
},

main: {
Expand All @@ -13,10 +14,7 @@ const styles = StyleSheet.create({
justifyContent: 'center',
alignItems: 'center',
color: '#000',
},

margin: {
marginBottom: '16%',
marginTop: '20%',
},

normalText: {
Expand Down Expand Up @@ -50,8 +48,17 @@ const styles = StyleSheet.create({
alignItems: 'center',
},

image: {
height: 92,
messageNormal: {
marginTop: 0,
},

messageError: {
marginTop: 0,
color: 'red',
},

graphic: {
height: '60%',
},

footer: {
Expand Down
11 changes: 5 additions & 6 deletions src/screens/Auth/RegisterStack/RegisterScreen/RegisterScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,26 @@ export default function RegisterScreen(props: Props) {
const [email, setEmail] = useState('')
const {navigate} = props.navigation
const user = {
userTitle: props.navigation.state.params.userTitle,
companyCode: props.navigation.state.params.companyCode,
userRecord: props.navigation.state.params.userRecord,
}

return (
<View style={styles.container}>
<View style={styles.main}>
<BlackHeading title="What's your Email?" />
<Text style={styles.regularText}>Make sure to use your work email so we can match you to your employer</Text>
<GreyTextInput changeTextContent={(name) => setName(name)} placeholder="Name" inputType='text' input={name}/>
<Text style={styles.margin}></Text>
<GreyTextInput changeTextContent={(email) => setEmail(email)} placeholder="Email Address" inputType='emailAddress' input={email}/>
<PinkButton title="CONTINUE"
onPress={
() => navigate('CreatePassword', {
userTitle: user.userTitle,
companyCode: user.companyCode,
name: name,
email: email
email: email,
userRecord: user.userRecord,
})
}
disabled={!name || !email}
disabled={!email}
/>
</View>
<View style={styles.footer}>
Expand Down
4 changes: 4 additions & 0 deletions src/screens/Auth/RegisterStack/RegisterScreen/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const styles = StyleSheet.create({
color: '#000',
},

margin: {
marginBottom: '20%',
},

regularText: {
fontSize: 16,
fontFamily: 'roboto-regular',
Expand Down
Loading

0 comments on commit 21c5f40

Please sign in to comment.