From 3ab975ba9236c0adf84f463499cf818970c1047e Mon Sep 17 00:00:00 2001 From: Mohammed Fahim Ahmed Date: Tue, 5 Mar 2019 15:36:20 -0500 Subject: Implemented JSON from app to server, build valid, contains all info, Form Page updated to meet specifications, submit button works --- mobile/screens/Form1.js | 87 ++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 44 deletions(-) (limited to 'mobile') 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 ( - - - - Age: + + Age: this.setState({age})} + onChangeText={(text) => this.setState({age:text})} /> - - - Name: + Appearance: this.setState({name})} - /> - Appearance: - this.setState({appearance})} /> - Injured? - {/* insert radio button???*/} - Please let us know why do you think they need help + Are they injured? this.setState({why})} + placeholder="If so, please explain the injury" + onChangeText={(injured) => this.setState({injured})} /> - - {/*additional questions*/} - -