Skip to content

Commit

Permalink
fix demo api address to heroku
Browse files Browse the repository at this point in the history
  • Loading branch information
noahschutte committed Aug 11, 2016
1 parent d390695 commit de06a28
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 33 deletions.
2 changes: 2 additions & 0 deletions ios/Raop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@
"$(SRCROOT)/../node_modules/react-native-fbsdk/ios/RCTFBSDK/**",
);
INFOPLIST_FILE = Raop/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down Expand Up @@ -724,6 +725,7 @@
"$(SRCROOT)/../node_modules/react-native-fbsdk/ios/RCTFBSDK/**",
);
INFOPLIST_FILE = Raop/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down
Binary file not shown.
2 changes: 2 additions & 0 deletions ios/Raop/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
Expand Down
3 changes: 2 additions & 1 deletion src/components/FBLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export default class Login extends Component {
.then((response) => {
return response.json()})
.then((responseJson) => {
this.props.onUserChange(responseJson)
this.props.onUserChange(responseJson.user)
this.props.onEmailChange(responseJson.email)
})
.catch((error) => {
console.error(error);
Expand Down
3 changes: 3 additions & 0 deletions src/components/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default class Requests extends Component {
this.setState({errorMessage: responseJson.errorMessage})
} else {
this.setState({errorMessage: ' '})
this.props.onEmailChange(responseJson.email)
this.props.sumDonatedPizzas(responseJson.totalDonatedPizzas)
this.props.collectRequests(responseJson.requests)
}
Expand Down Expand Up @@ -87,6 +88,7 @@ export default class Requests extends Component {
if (this.props.user === null) {
showLoginDialog = <Login
onUserChange={this.props.onUserChange}
onEmailChange={this.props.onEmailChange}
navigator={this.props.navigator}
/>
}
Expand All @@ -102,6 +104,7 @@ export default class Requests extends Component {

let currentRequests;
if (this.state.errorMessage === " ") {
console.log(this.props.user);
currentRequests = <Swiper style={styles.wrapper} showsButtons={true}>
{this.props.requests.map((request, i) => {
let requestID = request.id
Expand Down
17 changes: 0 additions & 17 deletions src/components/signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,6 @@ import { View, Text, StyleSheet } from 'react-native';
import Button from './button';

export default class Signin extends Component {
constructor(props) {
super(props)

this.state = {
totalDonatedPizzas: null
}
}
componentWillMount() {
fetch(`http://random-acts-of-pizza.herokuapp.com/users`)
.then((response) => response.json())
.then((responseJson) => {
this.setState({totalDonatedPizzas: responseJson.totalDonatedPizzas})
})
.catch((error) => {
console.error(error);
});
}
onRequestsPress() {
this.props.navigator.push({name: 'requests'});
}
Expand Down
28 changes: 14 additions & 14 deletions src/components/user_profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default class UserProfile extends Component {
super(props)

this.state = {
currentEmail: 'loading...',
updatedEmail: '',
errorMessage: ' '
};
Expand All @@ -20,17 +19,17 @@ export default class UserProfile extends Component {
onBackPress() {
this.props.navigator.pop();
}
componentDidMount() {
const userID = this.props.user.id
fetch(`http://random-acts-of-pizza.herokuapp.com/users/${userID}`)
.then((response) => response.json())
.then((responseJson) => {
this.setState({currentEmail: responseJson.email})
})
.catch((error) => {
console.error(error);
});
}
// componentDidMount() {
// const userID = this.props.user.id
// fetch(`http://localhost:3000/users/${userID}`)
// .then((response) => response.json())
// .then((responseJson) => {
// this.setState({currentEmail: responseJson.email})
// })
// .catch((error) => {
// console.error(error);
// });
// }
onUpdateEmailPress() {
const userID = this.props.user.id
const { updatedEmail } = this.state;
Expand All @@ -46,7 +45,7 @@ export default class UserProfile extends Component {
return response.json()})
.then((responseJson) => {
if (responseJson.email) {
this.setState({currentEmail: responseJson.email})
this.props.onEmailChange(responseJson.email)
this.setState({updatedEmail: ''})
this.setState({errorMessage: responseJson.errorMessage})
} else {
Expand All @@ -58,6 +57,7 @@ export default class UserProfile extends Component {
});
}
render() {
console.log(this.props.currentEmail);
let showFBButton;
if (true) {
showFBButton = <Login
Expand All @@ -81,7 +81,7 @@ export default class UserProfile extends Component {
</Text>

<Text>
{this.state.currentEmail}
{this.props.currentEmail}
</Text>

<Text>
Expand Down
7 changes: 6 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@ export default class Raop extends Component {

this.state = {
user: null,
currentEmail: '',
requests: [],
totalDonatedPizzas: null
}
this.onUserChange = this.onUserChange.bind(this);
this.onEmailChange = this.onEmailChange.bind(this);
this.collectRequests = this.collectRequests.bind(this);
this.sumDonatedPizzas = this.sumDonatedPizzas.bind(this);
this.renderScene = this.renderScene.bind(this);
}
onUserChange(user) {
this.setState({user})
}
onEmailChange(currentEmail) {
this.setState({currentEmail})
}
collectRequests(requests) {
this.setState({requests})
}
Expand All @@ -37,7 +42,7 @@ export default class Raop extends Component {
}
renderScene(route, navigator) {
const Component = ROUTES[route.name];
return <Component route={route} navigator={navigator} onUserChange={this.onUserChange} user={this.state.user} collectRequests={this.collectRequests} requests={this.state.requests} sumDonatedPizzas={this.sumDonatedPizzas} totalDonatedPizzas={this.state.totalDonatedPizzas}/>;
return <Component route={route} navigator={navigator} onUserChange={this.onUserChange} user={this.state.user} onEmailChange={this.onEmailChange} currentEmail={this.state.currentEmail} collectRequests={this.collectRequests} requests={this.state.requests} sumDonatedPizzas={this.sumDonatedPizzas} totalDonatedPizzas={this.state.totalDonatedPizzas}/>;
}
render() {
return (
Expand Down

0 comments on commit de06a28

Please sign in to comment.