Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
new_excelso
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Prasetya Saputra
new_excelso
Commits
d49738ca
Commit
d49738ca
authored
May 06, 2020
by
Wahyu Adjie Prasetyo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change location
parent
0ee7c8a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
93 deletions
+45
-93
MenuSelection.js
view/MenuSelection.js
+45
-93
No files found.
view/MenuSelection.js
View file @
d49738ca
...
...
@@ -7,9 +7,6 @@ import ActionType from '../redux/globalActionType';
import
CurrencyFormat
from
'react-currency-format'
;
import
_
from
'lodash'
;
import
session
from
'../function/session'
;
import
*
as
Location
from
'expo-location'
;
import
*
as
Permissions
from
'expo-permissions'
;
import
*
as
Device
from
'expo-device'
;
class
MenuSelection
extends
React
.
Component
{
constructor
(
props
)
{
...
...
@@ -24,8 +21,6 @@ class MenuSelection extends React.Component {
order_list
:
[],
list_cart
:
[],
indicator
:
true
,
my_lat
:
0
,
my_long
:
0
}
}
...
...
@@ -34,22 +29,17 @@ class MenuSelection extends React.Component {
if
(
this
.
props
.
outlet_id
!=
''
)
{
this
.
getMenuList
()
}
else
{
this
.
setState
({
indicator
:
true
})
this
.
_getPermissions
()
this
.
getMenuList
()
Alert
.
alert
(
'Device belum mendapatkan lokasi anda'
)
}
// console.log("INI OUTLET : "+ this.props.outlet_id)
this
.
_unsubscribe
=
this
.
props
.
navigation
.
addListener
(
'focus'
,
()
=>
{
if
(
this
.
props
.
outlet_id
!=
''
)
{
this
.
getMenuList
()
}
else
{
this
.
setState
({
indicator
:
true
indicator
:
true
})
this
.
_getPermissions
()
this
.
getMenuList
()
}
else
{
Alert
.
alert
(
'Device belum mendapatkan lokasi anda'
)
}
});
}
...
...
@@ -58,66 +48,35 @@ class MenuSelection extends React.Component {
this
.
_unsubscribe
();
}
_getPermissions
=
async
()
=>
{
let
{
status
}
=
await
Permissions
.
askAsync
(
Permissions
.
LOCATION
);
if
(
status
!==
'granted'
)
{
Alert
.
alert
(
'Akses tidak dizinkan!'
)
}
else
if
(
Platform
.
OS
===
'android'
&&
!
Device
.
isDevice
)
{
Alert
.
alert
(
'Silahkan anda coba di real Device'
)
}
else
{
this
.
_getCurrentPosisition
()
}
}
_getCurrentPosisition
=
async
()
=>
{
this
.
setState
({
spinner
:
true
,
})
let
location
=
await
Location
.
getCurrentPositionAsync
({
accuracy
:
Location
.
Accuracy
.
Highest
})
let
latitude
=
location
.
coords
.
latitude
;
let
longitude
=
location
.
coords
.
longitude
;
this
.
setState
({
my_lat
:
latitude
,
my_long
:
longitude
})
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
})
}).
catch
(
error
=>
{
const
{
navigation
}
=
this
.
props
let
response
=
error
.
response
.
data
session
(
response
,
navigation
)
Alert
.
alert
(
response
.
msg
);
})
}
// _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
// })
// }).catch(error => {
// const {navigation} = this.props
// let response = error.response.data
// session(response,navigation)
// Alert.alert(response.msg);
// })
// }
getMenuList
()
{
let
params
=
{
...
...
@@ -167,9 +126,9 @@ class MenuSelection extends React.Component {
this
.
props
.
updateMenu
(
data
.
menu
)
}).
catch
(
error
=>
{
const
{
navigation
}
=
this
.
props
const
{
navigation
}
=
this
.
props
let
response
=
error
.
response
.
data
session
(
response
,
navigation
)
session
(
response
,
navigation
)
Alert
.
alert
(
response
.
msg
);
})
...
...
@@ -301,18 +260,18 @@ class MenuSelection extends React.Component {
)}
<
/View
>
<
View
style
=
{
styles
.
shadow
}
>
{
this
.
state
.
indicator
==
true
?
(
<
ActivityIndicator
style
=
{{
top
:
10
}}
size
=
"large"
color
=
"#c9af6d"
/>
)
:
(
<
View
style
=
{{
flexDirection
:
'row'
,
}}
>
{
this
.
state
.
indicator
==
true
?
(
<
ActivityIndicator
style
=
{{
top
:
10
}}
size
=
"large"
color
=
"#c9af6d"
/>
):
(
<
View
style
=
{{
flexDirection
:
'row'
,
}}
>
<
Text
style
=
{{
fontSize
:
12
,
margin
:
10
}}
>
Price
Estimation
/
Item
{
this
.
props
.
order_quantity
}
<
/Text
>
<
Text
style
=
{{
fontSize
:
12
,
margin
:
10
}}
>
Ongkir
{
this
.
props
.
grabamount
}
<
/Text
>
<
Text
style
=
{{
fontSize
:
20
,
margin
:
10
,
marginBottom
:
10
}}
>
Rp
.
{
this
.
props
.
order_total
}
<
/Text
>
<
/View
>
)
}
<
Text
style
=
{{
fontSize
:
20
,
margin
:
10
,
marginBottom
:
10
}}
>
Rp
.
{
this
.
props
.
order_total
}
<
/Text
>
<
/View
>
)
}
<
View
>
<
Button
title
=
"VIEW CART"
onPress
=
{()
=>
this
.
props
.
navigation
.
navigate
(
'Shopping Cart'
)}
><
/Button
>
<
/View
>
...
...
@@ -380,13 +339,6 @@ const mapDispatchToProps = (dispacth) => {
item
:
item
}
}),
setChangeOutletProps
:
(
OutletChange
)
=>
dispacth
({
type
:
ActionType
.
SET_CHANGE_OUTLET
,
data
:
{
outlet_id
:
OutletChange
.
outlet_id
,
name_outlet
:
OutletChange
.
name_outlet
,
}
}),
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment