Commit 1f762bf6 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

Merge branch 'master' of ssh://repo.cs.co.id:2222/wahyu/bahanoprek

# Conflicts:
#	view/MenuSelection.js
parents d49738ca 8ab729d7
...@@ -29,7 +29,10 @@ class MenuSelection extends React.Component { ...@@ -29,7 +29,10 @@ class MenuSelection extends React.Component {
if (this.props.outlet_id != '') { if (this.props.outlet_id != '') {
this.getMenuList() this.getMenuList()
} else { } else {
Alert.alert('Device belum mendapatkan lokasi anda') this.setState({
indicator: true
})
this._getPermissions()
} }
// console.log("INI OUTLET : "+ this.props.outlet_id) // console.log("INI OUTLET : "+ this.props.outlet_id)
this._unsubscribe = this.props.navigation.addListener('focus', () => { this._unsubscribe = this.props.navigation.addListener('focus', () => {
...@@ -37,9 +40,7 @@ class MenuSelection extends React.Component { ...@@ -37,9 +40,7 @@ class MenuSelection extends React.Component {
this.setState({ this.setState({
indicator:true indicator:true
}) })
this.getMenuList() this._getPermissions()
} else {
Alert.alert('Device belum mendapatkan lokasi anda')
} }
}); });
} }
...@@ -48,35 +49,67 @@ class MenuSelection extends React.Component { ...@@ -48,35 +49,67 @@ class MenuSelection extends React.Component {
this._unsubscribe(); this._unsubscribe();
} }
// _getOutletClosest() {
// let params = { _getPermissions = async () => {
// session_id: this.props.session_id, let { status } = await Permissions.askAsync(Permissions.LOCATION);
// lat: this.state.my_lat, if (status !== 'granted') {
// long: this.state.my_long Alert.alert('Akses tidak dizinkan!')
// } } else if (Platform.OS === 'android' && !Device.isDevice) {
// // console.log(params);
// Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/outlet/get_closest', params).then((res) => { Alert.alert('Silahkan anda coba di real Device')
} else {
this._getCurrentPosisition()
// let outletId = res.data.data.outlet_id }
// let outletName = res.data.data.outlet_name }
_getCurrentPosisition = async () => {
// let OutletChange = { this.setState({
// outlet_id: outletId, spinner: true,
// name_outlet: outletName, })
// } let location = await Location.getCurrentPositionAsync({
// this.props.setChangeOutletProps(OutletChange); accuracy: Location.Accuracy.Highest
// this.setState({ })
// indicator: false
// }) let latitude = location.coords.latitude;
let longitude = location.coords.longitude;
// }).catch(error => {
// const {navigation} = this.props this.setState({
// let response = error.response.data my_lat: latitude,
// session(response,navigation) my_long: longitude
// Alert.alert(response.msg); })
// })
// } this._getOutletClosest();
}
_getOutletClosest() {
let params = {
session_id: this.props.session_id,
lat: this.state.my_lat,
long: this.state.my_long
}
// console.log(params);
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/outlet/get_closest', params).then((res) => {
let outletId = res.data.data.outlet_id
let outletName = res.data.data.outlet_name
let OutletChange = {
outlet_id: outletId,
name_outlet: outletName,
}
this.props.setChangeOutletProps(OutletChange);
this.setState({
indicator: false
})
this.getMenuList()
}).catch(error => {
const { navigation } = this.props
let response = error.response.data
session(response, navigation)
Alert.alert(response.msg);
})
}
getMenuList() { getMenuList() {
let params = { let params = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment