Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
clone_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
clone_excelso
Commits
0ee7c8a8
Commit
0ee7c8a8
authored
May 06, 2020
by
Wahyu Adjie Prasetyo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tambah di menu
parent
6f339910
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
48 deletions
+96
-48
Home.js
view/Home.js
+4
-2
MenuSelection.js
view/MenuSelection.js
+92
-46
No files found.
view/Home.js
View file @
0ee7c8a8
...
...
@@ -31,16 +31,18 @@ class Home extends React.Component {
}
componentDidMount
()
{
this
.
_account
();
this
.
_getPermissions
()
this
.
_renderCarousell
()
this
.
_account
();
this
.
_unsubscribe
=
this
.
props
.
navigation
.
addListener
(
'focus'
,
()
=>
{
this
.
setState
({
indicator
:
true
,
})
this
.
_account
();
this
.
_getPermissions
()
this
.
_renderCarousell
()
this
.
_account
();
});
}
...
...
view/MenuSelection.js
View file @
0ee7c8a8
...
...
@@ -7,6 +7,9 @@ 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
)
{
...
...
@@ -21,26 +24,32 @@ class MenuSelection extends React.Component {
order_list
:
[],
list_cart
:
[],
indicator
:
true
,
my_lat
:
0
,
my_long
:
0
}
}
componentDidMount
()
{
if
(
this
.
props
.
outlet_id
!=
''
)
{
this
.
getMenuList
()
}
else
{
Alert
.
alert
(
'Device belum mendapatkan lokasi anda'
)
this
.
setState
({
indicator
:
true
})
this
.
_getPermissions
()
this
.
getMenuList
()
}
// 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'
)
}
});
}
...
...
@@ -50,35 +59,65 @@ class MenuSelection extends React.Component {
}
// _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);
// })
// }
_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
);
})
}
getMenuList
()
{
let
params
=
{
...
...
@@ -128,9 +167,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
);
})
...
...
@@ -262,18 +301,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
>
...
...
@@ -341,6 +380,13 @@ 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