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
c5203ecc
Commit
c5203ecc
authored
Apr 28, 2020
by
Wahyu Adjie Prasetyo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shoping cart
parent
e19c59a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
106 additions
and
74 deletions
+106
-74
MenuConfirmation.js
view/MenuConfirmation.js
+2
-2
ShoppingCart.js
view/ShoppingCart.js
+104
-72
No files found.
view/MenuConfirmation.js
View file @
c5203ecc
...
...
@@ -103,7 +103,7 @@ class MenuConfirmation extends React.Component {
<
Text
>
Total
<
/Text
>
<
/View
>
<
View
style
=
{{
margin
:
10
}}
>
<
Text
>
0
<
/Text
>
<
Text
>
{
this
.
props
.
order_total
+
this
.
props
.
grabamount
+
this
.
state
.
diskon
}
<
/Text
>
<
/View
>
<
/View
>
<
View
style
=
{{
flexDirection
:
'row'
,
margin
:
10
,
justifyContent
:
'space-between'
,
borderTopWidth
:
1
}}
>
...
...
@@ -178,7 +178,7 @@ const mapStateToProps = (state) => {
grabdropoff
:
state
.
grabdropoff
,
grabdestination
:
state
.
grabdestination
,
balanceUsed
:
state
.
balanceUsed
,
pointused
:
state
.
point
s
used
,
pointused
:
state
.
pointused
,
addressId
:
state
.
addressId
}
}
...
...
view/ShoppingCart.js
View file @
c5203ecc
...
...
@@ -79,20 +79,8 @@ class ShoppingCart extends React.Component {
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
)
}
}
}
...
...
@@ -118,11 +106,6 @@ class ShoppingCart extends React.Component {
quantity
=
is_xist
.
quantity
}
const
listMenu
=
[...
this
.
state
.
listMenu
]
listMenu
[
index
].
qty
=
quantity
this
.
setState
({
listMenu
})
}
checkedSelection
(
val
)
{
...
...
@@ -170,73 +153,114 @@ class ShoppingCart extends React.Component {
componentDidMount
()
{
this
.
getMenuList
()
this
.
getBalance
()
this
.
getRate
()
}
getMenuList
()
{
let
params
=
{
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
})
// getMenuList() {
// let params = {
// 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)
// }
// }
// this.setState({
// listMenu: list_menu
// })
// })
// }
let
last_category
=
''
let
list_menu
=
[]
getRate
()
{
for
(
let
i
=
0
;
i
<
data
.
menu
.
length
;
i
++
)
{
if
(
this
.
props
.
outlet_id
===
''
)
{
let
params
=
{
const
row
=
data
.
menu
[
i
];
session_id
:
this
.
props
.
session_id
,
outlet_id
:
'0cb81ffe0c8242bea42d39c9b92ccaac'
,
address_id
:
this
.
props
.
addressId
,
order_item
:
this
.
props
.
order_item
}
// 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
}
Axios
.
post
(
'https://excelsocrm.ravintoladev.com/crm/v2/delivery/rate'
,
params
).
then
(
res
=>
{
console
.
log
(
"INI LHO CUY : "
+
JSON
.
stringify
(
res
.
data
.
data
.
destination
.
address
))
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
})
})
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
,
}
})
getRate
()
{
let
setGrabProps
=
{
grabtype
:
this
.
state
.
grabtype
,
grabamount
:
this
.
state
.
grabamount
,
grabpickup
:
this
.
state
.
grabpickup
,
grabdropoff
:
this
.
state
.
grabdropoff
,
grabdestination
:
this
.
state
.
grabdestination
,
}
let
params
=
{
this
.
props
.
setGrab
(
setGrabProps
);
session_id
:
this
.
props
.
session_id
,
outlet_id
:
'0cb81ffe0c8242bea42d39c9b92ccaac'
,
address_id
:
'6263e6cb70634d5da523345a2cdbc071'
,
order_item
:
this
.
props
.
order_item
}
let
setOrdersProps
=
{
balanceUsed
:
this
.
state
.
balanceused
,
pointused
:
this
.
state
.
pointsused
,
}
this
.
props
.
setOrder
(
setOrdersProps
);
console
.
log
(
"INI PARAMETER : "
+
JSON
.
stringify
(
params
));
Axios
.
post
(
'https://excelsocrm.ravintoladev.com/crm/v2/delivery/rate'
,
params
).
then
(
res
=>
{
}).
catch
(
error
=>
{
console
.
log
(
'ini error '
+
error
)
})
}
else
{
let
params
=
{
session_id
:
this
.
props
.
session_id
,
outlet_id
:
this
.
props
.
outlet_id
,
address_id
:
this
.
props
.
addressId
,
order_item
:
this
.
props
.
order_item
}
Axios
.
post
(
'https://excelsocrm.ravintoladev.com/crm/v2/delivery/rate'
,
params
).
then
(
res
=>
{
console
.
log
(
"INI LHO CUY : "
+
JSON
.
stringify
(
res
.
data
.
data
.
destination
.
address
))
this
.
setState
({
...
...
@@ -268,6 +292,9 @@ class ShoppingCart extends React.Component {
}).
catch
(
error
=>
{
console
.
log
(
'ini error '
+
error
)
})
}
}
getBalance
()
{
...
...
@@ -519,7 +546,7 @@ class ShoppingCart extends React.Component {
<
Text
style
=
{{
fontSize
:
35
,
color
:
'#ccb46c'
}}
>
Total
<
/Text
>
<
/View
>
<
View
style
=
{{
marginTop
:
15
,
paddingRight
:
30
,
paddingTop
:
10
,
alignItems
:
'flex-end'
}}
>
<
Text
style
=
{{
fontSize
:
35
,
color
:
'#ccb46c'
}}
>
{
this
.
props
.
order_total
}
<
/Text
>
<
Text
style
=
{{
fontSize
:
35
,
color
:
'#ccb46c'
}}
>
{
this
.
props
.
order_total
+
this
.
props
.
grabamount
+
this
.
state
.
diskon
}
<
/Text
>
<
/View
>
<
/View
>
<
View
style
=
{{
flexDirection
:
'row'
,
marginTop
:
10
,
justifyContent
:
'space-between'
}}
>
...
...
@@ -708,7 +735,7 @@ const mapDispatchToProps = (dispacth) => {
type
:
ActionType
.
SET_ORDERS
,
data
:
{
balanceUsed
:
setOrdersProps
.
balanceUsed
,
pointused
:
setOrdersProps
.
point
s
used
,
pointused
:
setOrdersProps
.
pointused
,
}
}),
}
...
...
@@ -723,7 +750,12 @@ const mapStateToProps = (state) => {
order_item
:
state
.
order_item
,
quantity
:
state
.
quantity
,
address
:
state
.
address
,
addressId
:
state
.
addressId
addressId
:
state
.
addressId
,
grabtype
:
state
.
grabtype
,
grabamount
:
state
.
grabamount
,
grabpickup
:
state
.
grabpickup
,
grabdropoff
:
state
.
grabdropoff
,
grabdestination
:
state
.
grabdestination
,
}
}
...
...
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