Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issues 1, 3, 5 #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions aws-exports.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const config = {
identityPoolId: 'us-east-2:2d550536-b16e-4998-83d9-341ed50e2a9d',
identityPoolId: 'us-east-2:aec9ba3d-3e3f-4e1f-9090-a60fd769e895',
region: 'us-east-2',
userPoolId: 'us-east-2_TPSepruyZ',
userPoolWebClientId: '3c311eos0ca1ha9tkp8fleui85'
userPoolId: 'us-east-2_fzKjLKOW3',
userPoolWebClientId: '3sider0qtjrjfdudk3g5vor6sk'
}
export default config
22 changes: 8 additions & 14 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,18 @@ function signUpFailure(err) {
}
}

export function createUser(username, password, email, phone_number) {
export function createUser(username, password) {
return (dispatch) => {
dispatch(signUp())
let phone
const firstTwoDigits = phone_number.substring(0, 2)
const firstTwoDigits = username.substring(0, 2)
if (firstTwoDigits === '+1') {
phone = phone_number
username = username
} else {
phone = '+1' + phone_number
username = '+1' + username
}
Auth.signUp({
username,
password,
attributes: {
email,
phone_number: phone
}
})
.then(data => {
console.log('data from signUp: ', data)
Expand All @@ -64,6 +59,9 @@ export function createUser(username, password, email, phone_number) {
})
.catch(err => {
console.log('error signing up: ', err)
if ("1" == err.message.substring(0, 1)) {
err.message = "Password must have length greater than or equal to 6"
}
dispatch(signUpFailure(err))
});
}
Expand Down Expand Up @@ -160,15 +158,11 @@ function confirmLoginFailure() {
}

export function confirmUserSignUp(username, authCode) {
return (dispatch) => {
dispatch(confirmSignUp())
return (dispatch, getState) => {
Auth.confirmSignUp(username, authCode)
.then(data => {
console.log('data from confirmSignUp: ', data)
dispatch(confirmSignUpSuccess())
setTimeout(() => {
Alert.alert('Successfully Signed Up!', 'Please Sign')
}, 0)
})
.catch(err => {
console.log('error signing up: ', err)
Expand Down
7 changes: 3 additions & 4 deletions src/auth/SignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class SignIn extends Component<{}> {
}

render() {
const { fontsLoaded } = this.state
const { auth: {
signInErrorMessage,
isAuthenticating,
Expand All @@ -61,14 +60,14 @@ class SignIn extends Component<{}> {
/>
</View>
<Text style={[styles.greeting]}>
Welcome back,
Sign In
</Text>
<Text style={[styles.greeting2]}>
Let's eat together.
Let's help you order food.
</Text>
<View style={styles.inputContainer}>
<Input
placeholder="User Name"
placeholder="Phone Number"
type='username'
onChangeText={this.onChangeText}
value={this.state.username}
Expand Down
34 changes: 12 additions & 22 deletions src/auth/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import Button from '../components/Button'
const initialState = {
username: '',
password: '',
email: '',
phone_number: '',
authCode: ''
}

Expand All @@ -38,8 +36,8 @@ class SignUp extends Component<{}> {
}

signUp() {
const { username, password, email, phone_number } = this.state
this.props.dispatchCreateUser(username, password, email, phone_number)
const { username, password } = this.state
this.props.dispatchCreateUser(username, password)
}

confirm() {
Expand All @@ -61,6 +59,10 @@ class SignUp extends Component<{}> {
signUpError,
signUpErrorMessage
}} = this.props
// let user = this.props.auth.user
// if ( Object.keys(user).length === 0 && user.constructor === Object) {
// console.log('empty');
// }
return (
<View style={styles.container}>
<View style={styles.heading}>
Expand All @@ -71,23 +73,17 @@ class SignUp extends Component<{}> {
/>
</View>
<Text style={styles.greeting}>
Welcome,
Sign Up
</Text>
<Text style={styles.greeting2}>
Let's make an account for you.
Let's get you started.
</Text>
<View style={styles.inputContainer}>
<Input
value={this.state.username}
placeholder="User Name"
placeholder="Phone Number"
type='username'
onChangeText={this.onChangeText}
/>
<Input
value={this.state.email}
placeholder="Email"
type='email'
onChangeText={this.onChangeText}
value={this.state.username}
/>
<Input
value={this.state.password}
Expand All @@ -96,13 +92,7 @@ class SignUp extends Component<{}> {
type='password'
onChangeText={this.onChangeText}
/>
<Input
placeholder="Phone Number"
type='phone_number'
keyboardType='numeric'
onChangeText={this.onChangeText}
value={this.state.phone_number}
/>

</View>
<Button
title='Sign Up'
Expand Down Expand Up @@ -143,7 +133,7 @@ const mapStateToProps = state => ({

const mapDispatchToProps = {
dispatchConfirmUser: (username, authCode) => confirmUserSignUp(username, authCode),
dispatchCreateUser: (username, password, email, phone_number) => createUser(username, password, email, phone_number)
dispatchCreateUser: (username, password) => createUser(username, password)
}

export default connect(mapStateToProps, mapDispatchToProps)(SignUp)
Expand Down
11 changes: 10 additions & 1 deletion src/auth/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const routes = {
}

const routeConfig = {
initialRouteName: 'SignIn',
tabBarPosition: 'bottom',
tabBarOptions: {
showLabel: true,
Expand All @@ -57,5 +58,13 @@ const routeConfig = {
},
}
}
const BottomTab = createBottomTabNavigator(routes, routeConfig)

export default createBottomTabNavigator(routes, routeConfig)
class Tab extends React.Component {
render() {
return(
<BottomTab/>
)
}
}
export default Tab