aboutsummaryrefslogtreecommitdiff
path: root/mobile/screens/Form1.js
diff options
context:
space:
mode:
authorAndrewMihai <41450954+AndrewMihai@users.noreply.github.com>2019-03-08 21:18:06 +0000
committerGitHub <noreply@github.com>2019-03-08 21:18:06 +0000
commite8c968d4cc316b350d0402b77f45d71b107440b5 (patch)
treeaeae2c4212ace58b1f919f92c4cc821fa05d1cd9 /mobile/screens/Form1.js
parent16a1db718890bed4cdb802db252819cfab4d5329 (diff)
parent850937e8de7448f12af126047e4e270fb9976473 (diff)
Merge pull request #29 from csc301-winter-2019/feat/5
Feat/5
Diffstat (limited to 'mobile/screens/Form1.js')
-rw-r--r--mobile/screens/Form1.js86
1 files changed, 86 insertions, 0 deletions
diff --git a/mobile/screens/Form1.js b/mobile/screens/Form1.js
new file mode 100644
index 0000000..16ced64
--- /dev/null
+++ b/mobile/screens/Form1.js
@@ -0,0 +1,86 @@
+import React, { Component } from 'react';
+import {Text, Alert, AppRegistry, StyleSheet, View } from 'react-native';
+import { Button, Input, CheckBox } from 'react-native-elements';
+
+export default class Form1 extends Component {
+ _onPressButton1() {
+ const { navigation } = this.props;
+ const coordinates = navigation.getParam('coordinates');
+ //var coordinates = this.coordinates ? coordinates : [];
+ fetch('https://helpthehome-qa.herokuapp.com/mobilerequest', {
+ method: 'POST',
+ headers: {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ 'coordinates': coordinates,
+ 'type': "Point",
+ 'isInjured': this.state.injured,
+ 'reasonForHelp': this.state.why,
+ 'ageRange': this.state.age,
+ 'clothingDescription': this.state.appearance
+ }),
+ });
+ // TODO: handle the response from the serve and decide what to display
+ // based on that
+ // for now just to back to the home page
+ Alert.alert("You will now be redirected to the main page");
+ this.props.navigation.navigate('GreetingPage');
+}
+ _onPressButton2() {
+ Alert.alert('Continue:')
+ }
+ constructor(props) {
+ super(props);
+ this.state = {
+ age: '',
+ appearance: '',
+ injured: false,
+ why: ''
+ };
+ }
+
+ render() {
+ return (
+ <View style={{padding: 40}}>
+ <Text>Age:</Text>
+ <Input
+ style={{height: 40}}
+ placeholder="Estimate is fine"
+ onChangeText={(age) => this.setState({age})}
+ />
+ <Text>Appearance:</Text>
+ <Input
+ style={{height: 40}}
+ placeholder="What are they wearing?"
+ onChangeText={(appearance) => this.setState({appearance})}
+ />
+ <CheckBox
+ center
+ title="Are they injured?"
+ checked={this.state.injured}
+ onPress={() => this.setState({ injured: !this.state.injured })}
+ />
+ <Text>Reason for help?</Text>
+ <Input
+ style={{height: 40}}
+ placeholder="Please keep it short"
+ onChangeText={(why) => this.setState({why})}
+ />
+ <View style={{padding: 40}}>
+ <Button
+ buttonStyle={{backgroundColor:"green"}}
+ onPress={() => this._onPressButton1()}
+ title="Submit!"
+ />
+ <Button
+ containerStyle={{paddingTop: 10}}
+ onPress={() => this.props.navigation.navigate('GreetingPage')}
+ title="Go Back"
+ />
+ </View>
+ </View>
+ );
+ }
+}