diff options
| author | AndrewMihai <41450954+AndrewMihai@users.noreply.github.com> | 2019-03-05 20:51:06 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-05 20:51:06 +0000 |
| commit | 4793f7fd526aa1e53ca5f157622417b79c1b0c27 (patch) | |
| tree | 2676c1051b190a26263cf9732f54814a3fd20030 /mobile/screens/Form1.js | |
| parent | e40e046cc7f62db42d0b634870da4de020e9108a (diff) | |
| parent | 3ab975ba9236c0adf84f463499cf818970c1047e (diff) | |
Merge pull request #23 from csc301-winter-2019/feat/15
Implemented JSON from app to server, build valid, contains all info, …
Diffstat (limited to 'mobile/screens/Form1.js')
| -rw-r--r-- | mobile/screens/Form1.js | 87 |
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> ); } } - - - - |
