aboutsummaryrefslogtreecommitdiff
path: root/mobile
diff options
context:
space:
mode:
authorMohammed Fahim Ahmed <k1630493@kcl.ac.uk>2019-03-05 20:36:20 +0000
committerMohammed Fahim Ahmed <k1630493@kcl.ac.uk>2019-03-05 20:36:20 +0000
commit3ab975ba9236c0adf84f463499cf818970c1047e (patch)
tree0c84f44709bcc1af8f7f1b83fe9c6afa158be822 /mobile
parent598c090d54d96b9d2ea3d5940358b2e8cf157357 (diff)
Implemented JSON from app to server, build valid, contains all info, Form Page updated to meet specifications, submit button worksfeat/15
Diffstat (limited to 'mobile')
-rw-r--r--mobile/screens/Form1.js87
1 files changed, 43 insertions, 44 deletions
diff --git a/mobile/screens/Form1.js b/mobile/screens/Form1.js
index 578317f..92eec30 100644
--- a/mobile/screens/Form1.js
+++ b/mobile/screens/Form1.js
@@ -3,74 +3,73 @@ import {Text, Alert, AppRegistry, Button, StyleSheet, View, TextInput } from 're
export default class Form1 extends Component {
_onPressButton1() {
- Alert.alert('Thanks for letting us know!')
- }
+ //const {navigation} = this.props;
+ //const coordinates = navigation.getparam('coordinates');
+ var coordinates = this.coordinates ? coordinates : [];
+ Alert.alert("Thank you for your response.")
+ 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
+ }),
+ });
+}
_onPressButton2() {
Alert.alert('Continue:')
}
constructor(props) {
super(props);
- this.state = {age: '',
- name: '',
- appearance: '',
- injured: false,
- why: ''};
+ this.state = {
+ age: '',
+ appearance: '',
+ injured: false,
+ why: ''
+ };
}
render() {
return (
-
-
- <View style={{padding: 40}}>
- <Text>Age:</Text>
+ <View style={{padding: 40}}>
+ <Text>Age:</Text>
<TextInput
style={{height: 40}}
placeholder="(Estimate if unknown)"
- onChangeText={(age) => this.setState({age})}
+ onChangeText={(text) => this.setState({age:text})}
/>
-
-
- <Text>Name:</Text>
+ <Text>Appearance:</Text>
<TextInput
style={{height: 40}}
- placeholder="Type the name here"
- onChangeText={(name) => this.setState({name})}
- />
- <Text>Appearance:</Text>
- <TextInput
- style={{height: 40}}
- placeholder="What are they Wearing"
+ placeholder="What are they wearing"
onChangeText={(appearance) => this.setState({appearance})}
/>
- <Text>Injured?</Text>
- {/* insert radio button???*/}
- <Text>Please let us know why do you think they need help</Text>
+ <Text>Are they injured?</Text>
<TextInput
style={{height: 40}}
- placeholder="Reason"
- onChangeText={(why) => this.setState({why})}
+ placeholder="If so, please explain the injury"
+ onChangeText={(injured) => this.setState({injured})}
/>
-
- {/*additional questions*/}
- <View style={{padding: 40}}>
- <Button
- onPress={this._onPressButton1}
- title="I do not have time to speak with the individual, Submit!"
+ <Text>Reason for help?</Text>
+ <TextInput
+ style={{height: 40}}
+ placeholder="Why does the individual require assistance"
+ onChangeText={(why) => this.setState({why})}
/>
- </View>
-
+ <View style={{padding: 40}}>
<Button
- onPress={this._onPressButton2}
- title="I have additional info!"
+ onPress={() => this._onPressButton1()}
+ title="Submit!"
/>
</View>
-
-
-
+ </View>
);
}
}
-
-
-
-