diff --git a/app/CreateGroup.js b/app/CreateGroup.js index 029e4fc..66c361c 100644 --- a/app/CreateGroup.js +++ b/app/CreateGroup.js @@ -36,23 +36,25 @@ export default class CreateGroup extends Component { } submitGroup() { - let groupSettings = { - groupName: this.state.groupName, - users: this.state.users, - privacy: this.state.privacy, - }; - AuthAxios({ - url: `/api/groups`, - method: `post`, - data:{groupSettings: groupSettings} - }) - .then(({data}) => { - }) - .catch((error) => { - alert('There was a problem creating your group') - }) - const { navigate } = this.props.navigation; - navigate('GroupsList'); + if (this.state.groupName) { + let groupSettings = { + groupName: this.state.groupName, + users: this.state.users, + privacy: this.state.privacy, + }; + AuthAxios({ + url: `/api/groups`, + method: `post`, + data:{groupSettings: groupSettings} + }) + .then(({data}) => { + }) + .catch((error) => { + alert('There was a problem creating your group') + }) + const { navigate } = this.props.navigation; + navigate('GroupsList'); + } } handleUserChange(userObj) { diff --git a/app/SignUp.js b/app/SignUp.js index 8ba5f7a..95e5514 100644 --- a/app/SignUp.js +++ b/app/SignUp.js @@ -25,11 +25,17 @@ export default class SignUp extends Component { long: position.coords.longitude }; - return AuthAxios({ + AuthAxios({ url: `/api/user/location`, method: 'put', data: location }) + .then(() => { + console.log('location updated'); + }) + .catch((err) => { + console.log('location failed to update: ', err); + }); } _signIn() { @@ -37,13 +43,17 @@ export default class SignUp extends Component { GoogleSignin.signIn() .then((user) => { this.setState({user: user}); - return this.saveLocation(); + return AuthAxios({ + url: '/api/user' + }) }) .then(({data}) => { this.setState({dbUser: data}); - if (!data.created) { + console.log('new user? ', data.created, data); + if (data.created === false) { navigate('HomePageTabs'); } + this.saveLocation(); }) .catch((err) => { console.log('Error: ', err); diff --git a/app/SplashScreen.js b/app/SplashScreen.js index 1e344d0..2f0f616 100644 --- a/app/SplashScreen.js +++ b/app/SplashScreen.js @@ -37,7 +37,11 @@ export default class SplashScreen extends Component { {enableHighAccuracy: false, timeout: 20000, maximumAge: 90000000000000} ); this.watchID = navigator.geolocation.watchPosition((position) => { - this.setState({lastPosition: position}, () => {this.saveLocation()}); + this.setState({lastPosition: position}, () => { + if (this.state.user) { + this.saveLocation() + } + }); }); }