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
6102760c
Commit
6102760c
authored
Apr 27, 2020
by
Wahyu Adjie Prasetyo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ini rdux grab dan order
parent
630880ee
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
190 additions
and
94 deletions
+190
-94
globalActionType.js
redux/globalActionType.js
+3
-1
globalReducer.js
redux/globalReducer.js
+28
-1
MenuConfirmation.js
view/MenuConfirmation.js
+18
-1
ShoppingCart.js
view/ShoppingCart.js
+141
-91
No files found.
redux/globalActionType.js
View file @
6102760c
...
...
@@ -25,7 +25,9 @@ const ActionType = {
ADD_TO_CHART
:
'ADD_TO_CHART'
,
REMOVE_FROM_CHART
:
'REMOVE_FROM_CHART'
,
REDUCE_QUANTITY_ITEM
:
'REDUCE_QUANTITY_ITEM'
,
SET_ADDRESS
:
'SET_ADDRESS'
SET_ADDRESS
:
'SET_ADDRESS'
,
SET_GRAB
:
'SET_GRAB'
,
SET_ORDERS
:
'SET_ORDERS'
}
...
...
redux/globalReducer.js
View file @
6102760c
...
...
@@ -60,7 +60,16 @@ const globalState = {
address
:
''
,
addressId
:
''
addressId
:
''
,
grabtype
:
''
,
grabamount
:
''
,
grabpickup
:
''
,
grabdropoff
:
''
,
grabdestination
:
''
,
balanceUsed
:
''
,
pointused
:
''
,
}
const
rootReducer
=
(
state
=
globalState
,
action
)
=>
{
...
...
@@ -79,6 +88,24 @@ const rootReducer = (state = globalState, action) => {
isEmailverif
:
action
.
data
.
isEmailverif
,
}
}
case
ActionType
.
SET_GRAB
:
{
return
{
...
state
,
grabtype
:
action
.
data
.
grabtype
,
grabamount
:
action
.
data
.
grabamount
,
grabpickup
:
action
.
data
.
grabpickup
,
grabdropoff
:
action
.
data
.
grabdropoff
,
grabdestination
:
action
.
data
.
grabdestination
,
}
}
case
ActionType
.
SET_ORDERS
:
{
return
{
...
state
,
balanceUsed
:
action
.
data
.
balanceUsed
,
pointused
:
action
.
data
.
pointused
,
}
}
case
ActionType
.
SET_PAGE
:
{
return
{
...
state
,
...
...
view/MenuConfirmation.js
View file @
6102760c
...
...
@@ -16,6 +16,16 @@ class MenuConfirmation extends React.Component {
}
}
componentDidMount
(){
console
.
log
(
" DESTINASI : "
+
this
.
props
.
grabdestination
)
console
.
log
(
"ONGKIR"
+
this
.
props
.
grabamount
)
console
.
log
(
"drop off"
+
this
.
props
.
grabdropoff
)
console
.
log
(
"pickup"
+
this
.
props
.
grabpickup
)
console
.
log
(
"type"
+
this
.
props
.
grabtype
)
console
.
log
(
"BALANCED"
+
this
.
props
.
balanceUsed
)
console
.
log
(
"POINT"
+
this
.
props
.
pointsused
)
}
render
()
{
console
.
log
(
this
.
props
)
let
total
=
0
...
...
@@ -136,7 +146,14 @@ const mapStateToProps = (state) => {
order_total
:
state
.
order_total
,
order_item
:
state
.
order_item
,
quantity
:
state
.
quantity
,
address
:
state
.
address
address
:
state
.
address
,
grabtype
:
state
.
grabtype
,
grabamount
:
state
.
grabamount
,
grabpickup
:
state
.
grabpickup
,
grabdropoff
:
state
.
grabdropoff
,
grabdestination
:
state
.
grabdestination
,
balanceUsed
:
state
.
balanceUsed
,
pointused
:
state
.
pointsused
,
}
}
...
...
view/ShoppingCart.js
View file @
6102760c
...
...
@@ -28,7 +28,12 @@ class ShoppingCart extends React.Component {
diskon
:
0
,
isDelivery
:
false
,
isPickUp
:
false
,
order_item
:
this
.
props
.
order_item
order_item
:
this
.
props
.
order_item
,
grabtype
:
''
,
grabamount
:
''
,
grabpickup
:
''
,
grabdropoff
:
''
,
grabdestination
:
''
,
// dummyBalance : 155000,
// dummyPoint : 20000
}
...
...
@@ -55,70 +60,70 @@ class ShoppingCart extends React.Component {
handleMin
(
item
,
index
)
{
const
list_order_item
=
this
.
props
.
order_item
;
let
is_xist
=
list_order_item
.
find
(
row
=>
row
.
id
==
item
.
id
)
if
(
is_xist
)
{
if
(
is_xist
.
quantity
!=
0
)
{
const
order_item
=
{
id
:
item
.
id
,
name
:
item
.
name
,
price
:
item
.
price
,
}
this
.
props
.
reduceQuantityItem
(
order_item
)
let
quantity
=
0
for
(
let
i
=
0
;
i
<
list_order_item
.
length
;
i
++
)
{
const
row
=
list_order_item
[
i
];
const
qty
=
list_order_item
[
i
];
if
(
row
.
id
==
item
.
id
)
{
quantity
=
row
.
quantity
}
const
listMenu
=
[...
this
.
state
.
listMenu
]
listMenu
[
index
].
qty
=
quantity
this
.
setState
({
listMenu
})
if
(
is_xist
.
quantity
!=
0
)
{
const
order_item
=
{
id
:
item
.
id
,
name
:
item
.
name
,
price
:
item
.
price
,
}
this
.
props
.
reduceQuantityItem
(
order_item
)
let
quantity
=
0
for
(
let
i
=
0
;
i
<
list_order_item
.
length
;
i
++
)
{
const
row
=
list_order_item
[
i
];
const
qty
=
list_order_item
[
i
];
if
(
row
.
id
==
item
.
id
)
{
quantity
=
row
.
quantity
}
const
listMenu
=
[...
this
.
state
.
listMenu
]
listMenu
[
index
].
qty
=
quantity
this
.
setState
({
listMenu
})
}
}
else
if
(
is_xist
.
quantity
==
0
)
{
const
order_item
=
{
id
:
item
.
id
,
name
:
item
.
name
,
price
:
item
.
price
,
}
this
.
props
.
removeFromChart
(
order_item
)
}
}
else
if
(
is_xist
.
quantity
==
0
)
{
const
order_item
=
{
id
:
item
.
id
,
name
:
item
.
name
,
price
:
item
.
price
,
}
this
.
props
.
removeFromChart
(
order_item
)
}
}
}
handleAdd
(
item
,
index
)
{
const
order_item
=
{
id
:
item
.
id
,
code
:
item
.
code
,
name
:
item
.
name
,
description
:
item
.
description
,
note
:
'jangan garing'
,
price
:
parseInt
(
item
.
price
),
id
:
item
.
id
,
code
:
item
.
code
,
name
:
item
.
name
,
description
:
item
.
description
,
note
:
'jangan garing'
,
price
:
parseInt
(
item
.
price
),
}
this
.
props
.
addToChart
(
order_item
)
const
list_order_item
=
this
.
props
.
order_item
;
let
is_xist
=
list_order_item
.
find
(
row
=>
row
.
id
==
item
.
id
)
let
quantity
=
0
if
(
is_xist
)
{
quantity
=
is_xist
.
quantity
quantity
=
is_xist
.
quantity
}
const
listMenu
=
[...
this
.
state
.
listMenu
]
listMenu
[
index
].
qty
=
quantity
this
.
setState
({
listMenu
listMenu
})
}
}
checkedSelection
(
val
)
{
// console.log(val)
...
...
@@ -167,57 +172,57 @@ class ShoppingCart extends React.Component {
this
.
getMenuList
()
this
.
getBalance
()
//
this.getRate()
this
.
getRate
()
}
getMenuList
()
{
let
params
=
{
outlet_id
:
"dec1abbb-95d0-46ae-a6cd-2bf306590f15"
outlet_id
:
"dec1abbb-95d0-46ae-a6cd-2bf306590f15"
}
Axios
.
post
(
'https://excelsocrm.ravintoladev.com/crm/v2/menu/get_list'
,
params
).
then
(
res
=>
{
let
data
=
res
.
data
.
data
this
.
setState
({
listCategory
:
data
.
category
,
listMenu
:
data
.
menu
})
let
last_category
=
''
let
list_menu
=
[]
for
(
let
i
=
0
;
i
<
data
.
menu
.
length
;
i
++
)
{
const
row
=
data
.
menu
[
i
];
// cari sudah ada belum di redux
let
is_xist
=
this
.
props
.
order_item
.
find
(
item
=>
row
.
id
==
item
.
id
)
if
(
is_xist
)
{
row
[
'qty'
]
=
is_xist
.
quantity
}
else
{
row
[
'qty'
]
=
0
}
if
(
last_category
!=
row
.
category
.
name
)
{
let
category
=
{
"id"
:
row
.
category
.
id
,
"name"
:
row
.
category
.
name
,
"code"
:
"CATEGORY"
}
list_menu
.
push
(
category
)
list_menu
.
push
(
row
)
last_category
=
row
.
category
.
name
}
else
{
list_menu
.
push
(
row
)
let
data
=
res
.
data
.
data
this
.
setState
({
listCategory
:
data
.
category
,
listMenu
:
data
.
menu
})
let
last_category
=
''
let
list_menu
=
[]
for
(
let
i
=
0
;
i
<
data
.
menu
.
length
;
i
++
)
{
const
row
=
data
.
menu
[
i
];
// cari sudah ada belum di redux
let
is_xist
=
this
.
props
.
order_item
.
find
(
item
=>
row
.
id
==
item
.
id
)
if
(
is_xist
)
{
row
[
'qty'
]
=
is_xist
.
quantity
}
else
{
row
[
'qty'
]
=
0
}
if
(
last_category
!=
row
.
category
.
name
)
{
let
category
=
{
"id"
:
row
.
category
.
id
,
"name"
:
row
.
category
.
name
,
"code"
:
"CATEGORY"
}
list_menu
.
push
(
category
)
list_menu
.
push
(
row
)
last_category
=
row
.
category
.
name
}
else
{
list_menu
.
push
(
row
)
}
}
}
this
.
setState
({
listMenu
:
list_menu
})
this
.
setState
({
listMenu
:
list_menu
})
})
}
}
getRate
()
{
...
...
@@ -229,10 +234,37 @@ class ShoppingCart extends React.Component {
order_item
:
this
.
props
.
order_item
}
console
.
log
(
"INI PARAMETER : "
+
JSON
.
stringify
(
params
)
);
console
.
log
(
"INI PARAMETER : "
+
JSON
.
stringify
(
params
));
Axios
.
post
(
'https://excelsocrm.ravintoladev.com/crm/v2/delivery/rate'
,
params
).
then
(
res
=>
{
console
.
log
(
"INI : "
+
JSON
.
stringify
(
res
.
data
))
console
.
log
(
"INI LHO CUY : "
+
JSON
.
stringify
(
res
.
data
.
data
.
destination
.
address
))
this
.
setState
({
grabtype
:
res
.
data
.
data
.
quotes
[
0
].
service
.
type
,
grabamount
:
res
.
data
.
data
.
quotes
[
0
].
amount
,
grabpickup
:
res
.
data
.
data
.
quotes
[
0
].
estimatedTimeline
.
pickup
,
grabdropoff
:
res
.
data
.
data
.
quotes
[
0
].
estimatedTimeline
.
dropoff
,
grabdestination
:
res
.
data
.
data
.
destination
.
address
,
})
let
setGrabProps
=
{
grabtype
:
this
.
state
.
grabtype
,
grabamount
:
this
.
state
.
grabamount
,
grabpickup
:
this
.
state
.
grabpickup
,
grabdropoff
:
this
.
state
.
grabdropoff
,
grabdestination
:
this
.
state
.
grabdestination
,
}
this
.
props
.
setGrab
(
setGrabProps
);
let
setOrdersProps
=
{
balanceUsed
:
this
.
state
.
balanceused
,
pointused
:
this
.
state
.
pointsused
,
}
this
.
props
.
setOrder
(
setOrdersProps
);
}).
catch
(
error
=>
{
console
.
log
(
'ini error '
+
error
)
})
...
...
@@ -499,7 +531,7 @@ class ShoppingCart extends React.Component {
<
/View
>
<
/View
>
<
View
style
=
{{
margin
:
20
,
}}
>
<
Button
title
=
'Checkout'
color
=
'#ccb46c'
onPress
=
{()
=>
this
.
getRate
(
)}
/
>
<
Button
title
=
'Checkout'
color
=
'#ccb46c'
onPress
=
{()
=>
this
.
props
.
navigation
.
navigate
(
'Confirm Your Order'
,
{
balanceUsed
:
this
.
state
.
balanceused
,
pointused
:
this
.
state
.
pointsused
}
)}
/
>
<
/View
>
<
/View
>
<
/ScrollView
>
...
...
@@ -661,6 +693,24 @@ const mapDispatchToProps = (dispacth) => {
item
:
item
}
}),
setGrab
:
(
setGrabProps
)
=>
dispacth
({
type
:
ActionType
.
SET_GRAB
,
data
:
{
grabtype
:
setGrabProps
.
grabtype
,
grabamount
:
setGrabProps
.
grabamount
,
grabpickup
:
setGrabProps
.
grabpickup
,
grabdropoff
:
setGrabProps
.
grabdropoff
,
grabdestination
:
setGrabProps
.
grabdestination
,
}
}),
setOrder
:
(
setOrdersProps
)
=>
dispacth
({
type
:
ActionType
.
SET_ORDERS
,
data
:
{
balanceUsed
:
setOrdersProps
.
balanceUsed
,
pointused
:
setOrdersProps
.
pointsused
,
}
}),
}
}
...
...
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