diff options
| author | Kumar Damani <damani.kumar@gmail.com> | 2019-03-14 17:26:18 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-14 17:26:18 +0000 |
| commit | 14cba540466c51ce58545e40178dff27898e551c (patch) | |
| tree | 18fb6f35b4139ef96e1cab4e620b788619f737bf | |
| parent | c7fbadd32feb1f3b00144545a8e13da3b6bccada (diff) | |
| parent | dadc8489761294dc67edc89d553395512c697c40 (diff) | |
Merge pull request #36 from csc301-winter-2019/setup-prod
Setup prod
| -rw-r--r-- | mobile/app.json | 7 | ||||
| -rw-r--r-- | mobile/screens/Form1.js | 13 | ||||
| -rw-r--r-- | web/app.js | 7 |
3 files changed, 20 insertions, 7 deletions
diff --git a/mobile/app.json b/mobile/app.json index c990fce..d3b1d16 100644 --- a/mobile/app.json +++ b/mobile/app.json @@ -27,6 +27,13 @@ }, "android": { "package": "com.yourcompany.yourappname" + }, + "extra": { + "apiUrl": { + "dev": "http://192.168.0.20:3000/mobilerequest", + "staging": "https://helpthehome-qa.herokuapp.com/mobilerequest", + "prod": "https://helpthehome-prod.herokuapp.com/mobilerequest" + } } } } diff --git a/mobile/screens/Form1.js b/mobile/screens/Form1.js index 16ced64..2a52499 100644 --- a/mobile/screens/Form1.js +++ b/mobile/screens/Form1.js @@ -1,13 +1,21 @@ import React, { Component } from 'react'; import {Text, Alert, AppRegistry, StyleSheet, View } from 'react-native'; import { Button, Input, CheckBox } from 'react-native-elements'; +import { Constants } from 'expo'; export default class Form1 extends Component { + getApiUrl() { + var releaseChannel = Constants.manifest.releaseChannel; + if (releaseChannel === undefined) return Constants.manifest.extra.apiUrl.dev + if (releaseChannel.indexOf('prod') !== -1) return Constants.manifest.extra.apiUrl.prod + if (releaseChannel.indexOf('staging') !== -1) return Constants.manifest.extra.apiUrl.staging + } + _onPressButton1() { const { navigation } = this.props; const coordinates = navigation.getParam('coordinates'); - //var coordinates = this.coordinates ? coordinates : []; - fetch('https://helpthehome-qa.herokuapp.com/mobilerequest', { + var uri = this.getApiUrl(); + fetch(uri, { method: 'POST', headers: { Accept: 'application/json', @@ -25,7 +33,6 @@ export default class Form1 extends Component { // 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() { @@ -26,11 +26,10 @@ var uri; if (env === 'development') { uri = 'mongodb://localhost:27017/helpthehome' // use for small testing only if really necessary - // uri = 'mongodb+srv://development:dreamteam@cluster0-krnr4.mongodb.net/helpthehome?retryWrites=true' -} else if (env === 'qa') { + // uri = 'mongodb+srv://development:dreamteam@cluster0-krnr4.mongodb.net/helpthehome_devel?retryWrites=true' +} else { + // for qa and production set it on heroku config vars uri = process.env.MONGODB_URI -} else if (env === 'production') { - uri = '' } // Mongoose connection to MongoDB |
