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
3cfeaef7
Commit
3cfeaef7
authored
May 13, 2020
by
Wahyu Adjie Prasetyo
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://repo.cs.co.id:2222/wahyu/bahanoprek
parents
b165c5d6
c03e6b0e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
210 additions
and
119 deletions
+210
-119
globalReducer.js
redux/globalReducer.js
+57
-55
MenuConfirmation.js
view/MenuConfirmation.js
+153
-64
No files found.
redux/globalReducer.js
View file @
3cfeaef7
import
ActionType
from
'./globalActionType'
;
import
ActionType
from
'./globalActionType'
;
import
{
Alert
}
from
'react-native'
;
import
{
Alert
}
from
'react-native'
;
const
globalState
=
{
const
globalState
=
{
...
@@ -50,9 +50,9 @@ const globalState = {
...
@@ -50,9 +50,9 @@ const globalState = {
outlet_id
:
''
,
outlet_id
:
''
,
name_outlet
:
''
,
name_outlet
:
''
,
type_pickup
:
true
,
type_pickup
:
true
,
type_trans
:
''
,
type_trans
:
''
,
quantity
:
0
,
quantity
:
0
,
orders
:
0
,
orders
:
0
,
...
@@ -64,26 +64,26 @@ const globalState = {
...
@@ -64,26 +64,26 @@ const globalState = {
order_quantity
:
0
,
order_quantity
:
0
,
order_total
:
0
,
order_total
:
0
,
address
:
''
,
address
:
''
,
addressId
:
''
,
addressId
:
''
,
grabtype
:
''
,
grabamount
:
''
,
grabpickup
:
''
,
grabdropoff
:
''
,
grabdestination
:
''
,
grabtype
:
''
,
balanceUsed
:
''
,
grabamount
:
''
,
pointused
:
''
,
grabpickup
:
''
,
grabdropoff
:
''
,
grabdestination
:
''
,
balanceUsed
:
''
,
trans_id
:
''
,
pointused
:
''
,
trans_id
:
''
,
lat
:
''
,
long
:
''
,
lat
:
''
,
voucher
:
[]
,
long
:
''
,
value_voucher
:
''
voucher
:[],
value_voucher
:
''
}
}
const
rootReducer
=
(
state
=
globalState
,
action
)
=>
{
const
rootReducer
=
(
state
=
globalState
,
action
)
=>
{
...
@@ -146,7 +146,7 @@ const rootReducer = (state = globalState, action) => {
...
@@ -146,7 +146,7 @@ const rootReducer = (state = globalState, action) => {
type_trans
:
action
.
data
.
type_trans
type_trans
:
action
.
data
.
type_trans
}
}
}
}
case
ActionType
.
SET_DEVICE_INFO
:
{
case
ActionType
.
SET_DEVICE_INFO
:
{
return
{
return
{
...
state
,
...
state
,
...
@@ -286,7 +286,7 @@ const rootReducer = (state = globalState, action) => {
...
@@ -286,7 +286,7 @@ const rootReducer = (state = globalState, action) => {
return
{
return
{
...
state
,
...
state
,
address
:
action
.
data
.
address
,
address
:
action
.
data
.
address
,
addressId
:
action
.
data
.
addressId
addressId
:
action
.
data
.
addressId
}
}
}
}
case
ActionType
.
SET_TRANS_ID
:
{
case
ActionType
.
SET_TRANS_ID
:
{
...
@@ -301,7 +301,7 @@ const rootReducer = (state = globalState, action) => {
...
@@ -301,7 +301,7 @@ const rootReducer = (state = globalState, action) => {
session_id
:
action
.
data
.
session_id
,
session_id
:
action
.
data
.
session_id
,
}
}
}
}
case
ActionType
.
ADD_TO_CHART
:
{
case
ActionType
.
ADD_TO_CHART
:
{
let
addedItem
=
action
.
data
.
item
let
addedItem
=
action
.
data
.
item
...
@@ -380,7 +380,7 @@ const rootReducer = (state = globalState, action) => {
...
@@ -380,7 +380,7 @@ const rootReducer = (state = globalState, action) => {
if
(
update
.
quantity
==
NaN
)
{
if
(
update
.
quantity
==
NaN
)
{
update
.
quantity
=
1
update
.
quantity
=
1
}
}
console
.
log
(
'Update : '
+
JSON
.
stringify
(
update
))
console
.
log
(
'Update : '
+
JSON
.
stringify
(
update
))
data
=
{
...
old_data
,
...
update
}
data
=
{
...
old_data
,
...
update
}
}
}
...
@@ -395,7 +395,7 @@ const rootReducer = (state = globalState, action) => {
...
@@ -395,7 +395,7 @@ const rootReducer = (state = globalState, action) => {
}
}
let
quantity
=
state
.
order_quantity
let
quantity
=
state
.
order_quantity
let
menu_item
=
[]
let
menu_item
=
[]
...
@@ -439,7 +439,7 @@ const rootReducer = (state = globalState, action) => {
...
@@ -439,7 +439,7 @@ const rootReducer = (state = globalState, action) => {
}
}
if
(
update
.
quantity
==
0
)
{
if
(
update
.
quantity
==
0
)
{
update
.
quantity
=
0
update
.
quantity
=
0
}
else
{
}
else
{
...
@@ -459,12 +459,12 @@ const rootReducer = (state = globalState, action) => {
...
@@ -459,12 +459,12 @@ const rootReducer = (state = globalState, action) => {
}
}
}
}
order_item
=
updated_data
order_item
=
updated_data
// } else {
// } else {
// // add
// // add
// addedItem.quantity = 1
// addedItem.quantity = 1
// console.log('Baru : ' + JSON.stringify(addedItem))
// console.log('Baru : ' + JSON.stringify(addedItem))
// order_item = [...state.order_item, addedItem]
// order_item = [...state.order_item, addedItem]
}
}
// if (state.order_quantity === 0 && state.order_total === 0) {
// if (state.order_quantity === 0 && state.order_total === 0) {
...
@@ -507,7 +507,7 @@ const rootReducer = (state = globalState, action) => {
...
@@ -507,7 +507,7 @@ const rootReducer = (state = globalState, action) => {
let
addedItem
=
action
.
data
.
item
let
addedItem
=
action
.
data
.
item
let
is_exist
=
state
.
order_item
.
find
(
item
=>
addedItem
.
id
==
item
.
id
)
let
is_exist
=
state
.
order_item
.
find
(
item
=>
addedItem
.
id
==
item
.
id
)
let
new_items
=
state
.
order_item
.
filter
(
item
=>
addedItem
.
id
!==
item
.
id
)
let
new_items
=
state
.
order_item
.
filter
(
item
=>
addedItem
.
id
!==
item
.
id
)
let
order_item
=
[]
let
order_item
=
[]
if
(
is_exist
)
{
if
(
is_exist
)
{
// update
// update
...
@@ -541,7 +541,7 @@ const rootReducer = (state = globalState, action) => {
...
@@ -541,7 +541,7 @@ const rootReducer = (state = globalState, action) => {
order_total
:
action
.
data
.
order_total
,
order_total
:
action
.
data
.
order_total
,
order_quantity
:
action
.
data
.
order_quantity
,
order_quantity
:
action
.
data
.
order_quantity
,
order_item
:
action
.
data
.
order_item
order_item
:
action
.
data
.
order_item
}
}
}
}
case
ActionType
.
SET_ORDER_FINISH
:
{
case
ActionType
.
SET_ORDER_FINISH
:
{
...
@@ -554,8 +554,10 @@ const rootReducer = (state = globalState, action) => {
...
@@ -554,8 +554,10 @@ const rootReducer = (state = globalState, action) => {
grabamount
:
0
,
grabamount
:
0
,
outlet_id
:
''
,
outlet_id
:
''
,
name_outlet
:
''
,
name_outlet
:
''
,
address_id
:
''
address_id
:
''
,
voucher
:
[],
value_voucher
:
''
}
}
}
}
case
ActionType
.
UPDATE_MENU
:
{
case
ActionType
.
UPDATE_MENU
:
{
...
@@ -568,13 +570,13 @@ const rootReducer = (state = globalState, action) => {
...
@@ -568,13 +570,13 @@ const rootReducer = (state = globalState, action) => {
for
(
let
i
=
0
;
i
<
state
.
order_item
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
state
.
order_item
.
length
;
i
++
)
{
const
row
=
state
.
order_item
[
i
];
const
row
=
state
.
order_item
[
i
];
let
is_updated
=
menu
.
find
(
item
=>
item
.
id
==
row
.
id
)
let
is_updated
=
menu
.
find
(
item
=>
item
.
id
==
row
.
id
)
// Update Price in Cart
// Update Price in Cart
if
(
is_updated
)
{
if
(
is_updated
)
{
row
.
price
=
parseInt
(
is_updated
.
price
)
row
.
price
=
parseInt
(
is_updated
.
price
)
}
}
quantity
+=
parseInt
(
row
.
quantity
)
quantity
+=
parseInt
(
row
.
quantity
)
total
+=
parseInt
(
row
.
price
)
*
parseInt
(
row
.
quantity
)
total
+=
parseInt
(
row
.
price
)
*
parseInt
(
row
.
quantity
)
...
@@ -588,24 +590,24 @@ const rootReducer = (state = globalState, action) => {
...
@@ -588,24 +590,24 @@ const rootReducer = (state = globalState, action) => {
// cari sudah ada belum di redux
// cari sudah ada belum di redux
let
is_xist
=
list_item
.
find
(
item
=>
row
.
id
==
item
.
id
)
let
is_xist
=
list_item
.
find
(
item
=>
row
.
id
==
item
.
id
)
if
(
is_xist
)
{
if
(
is_xist
)
{
row
[
'qty'
]
=
is_xist
.
quantity
row
[
'qty'
]
=
is_xist
.
quantity
}
else
{
}
else
{
row
[
'qty'
]
=
0
row
[
'qty'
]
=
0
}
}
if
(
last_category
!=
row
.
category
.
name
)
{
if
(
last_category
!=
row
.
category
.
name
)
{
let
category
=
{
let
category
=
{
"id"
:
row
.
category
.
id
,
"id"
:
row
.
category
.
id
,
"name"
:
row
.
category
.
name
,
"name"
:
row
.
category
.
name
,
"code"
:
"CATEGORY"
"code"
:
"CATEGORY"
}
}
list_menu
.
push
(
category
)
list_menu
.
push
(
category
)
list_menu
.
push
(
row
)
list_menu
.
push
(
row
)
last_category
=
row
.
category
.
name
last_category
=
row
.
category
.
name
}
else
{
}
else
{
list_menu
.
push
(
row
)
list_menu
.
push
(
row
)
}
}
}
}
return
{
return
{
...
state
,
...
state
,
...
@@ -613,7 +615,7 @@ const rootReducer = (state = globalState, action) => {
...
@@ -613,7 +615,7 @@ const rootReducer = (state = globalState, action) => {
order_total
:
total
,
order_total
:
total
,
order_quantity
:
quantity
,
order_quantity
:
quantity
,
order_item
:
list_item
,
order_item
:
list_item
,
}
}
}
}
...
@@ -626,18 +628,18 @@ const rootReducer = (state = globalState, action) => {
...
@@ -626,18 +628,18 @@ const rootReducer = (state = globalState, action) => {
let
list_menu
=
[]
let
list_menu
=
[]
let
list_item
=
[]
let
list_item
=
[]
if
(
!
isNaN
(
parseInt
(
new_quantity
)))
{
if
(
!
isNaN
(
parseInt
(
new_quantity
)))
{
console
.
log
(
'Number : '
+
parseInt
(
new_quantity
))
console
.
log
(
'Number : '
+
parseInt
(
new_quantity
))
exist
=
false
exist
=
false
for
(
let
i
=
0
;
i
<
state
.
order_item
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
state
.
order_item
.
length
;
i
++
)
{
const
row
=
state
.
order_item
[
i
];
const
row
=
state
.
order_item
[
i
];
if
(
row
.
id
==
item
.
id
)
{
if
(
row
.
id
==
item
.
id
)
{
// Update Price in Cart
// Update Price in Cart
row
.
quantity
=
parseInt
(
new_quantity
)
row
.
quantity
=
parseInt
(
new_quantity
)
exist
=
true
exist
=
true
}
}
if
(
row
.
quantity
>
0
)
{
if
(
row
.
quantity
>
0
)
{
quantity
+=
parseInt
(
row
.
quantity
)
quantity
+=
parseInt
(
row
.
quantity
)
...
...
view/MenuConfirmation.js
View file @
3cfeaef7
...
@@ -48,74 +48,143 @@ class MenuConfirmation extends React.Component {
...
@@ -48,74 +48,143 @@ class MenuConfirmation extends React.Component {
}
}
// console.log(is_pickup)
// console.log(is_pickup)
let
params
=
{
if
(
this
.
props
.
value
==
''
)
{
session_id
:
this
.
props
.
session_id
,
let
params
=
{
outlet_id
:
this
.
props
.
outlet_id
,
session_id
:
this
.
props
.
session_id
,
address_id
:
this
.
props
.
addressId
,
outlet_id
:
this
.
props
.
outlet_id
,
trans_type
:
this
.
state
.
type
,
address_id
:
this
.
props
.
addressId
,
order_item
:
this
.
props
.
order_item
,
trans_type
:
this
.
state
.
type
,
delivery_charge
:
this
.
props
.
grabamount
,
order_item
:
this
.
props
.
order_item
,
voucher
:
[{
delivery_charge
:
this
.
props
.
grabamount
,
value
:
this
.
props
.
voucher
.
reward
.
value
,
voucher
:
[],
verification_number
:
this
.
props
.
voucher
.
verification_number
payment
:
{
}],
balance
:
this
.
props
.
route
.
params
.
balanceUsed
,
payment
:
{
point
:
this
.
props
.
route
.
params
.
pointused
balance
:
this
.
props
.
route
.
params
.
balanceUsed
,
}
point
:
this
.
props
.
route
.
params
.
pointused
}
}
}
console
.
log
(
params
)
console
.
log
(
params
)
Axios
.
post
(
'https://excelsocrm.ravintoladev.com/crm/v2/transaction/booking'
,
params
).
then
(
res
=>
{
Axios
.
post
(
'https://excelsocrm.ravintoladev.com/crm/v2/transaction/booking'
,
params
).
then
(
res
=>
{
let
data_order
=
res
.
data
.
data
.
id
let
data_order
=
res
.
data
.
data
.
id
this
.
setState
({
this
.
setState
({
spinner
:
false
,
spinner
:
false
,
})
let
transIdProps
=
{
trans_id
:
data_order
}
this
.
props
.
setTransId
(
transIdProps
);
// add API use voucher here
// let param = {
// session_id: this.props.session_id,
// reward_id: this.props.voucher.id,
// lat: this.props.lat,
// long: this.props.long
// }
// Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/reward/use_reward', param).then(res => {
// console.log(res.data)
// }).catch(error => {
// const { navigation } = this.props
// let response = error.response.data
// session(response, navigation)
// Alert.alert(response.msg);
// this.setState({
// spinner: false,
// })
// })
Alert
.
alert
(
"Berhasil"
,
"Transaksi sudah berhasil, terimakasih sudah menggunakan excelso untuk ngopi"
,
[
{
text
:
"OK"
,
onPress
:
()
=>
this
.
orderSuccess
()
}
],
{
cancelable
:
false
}
);
}).
catch
(
error
=>
{
const
{
navigation
}
=
this
.
props
let
response
=
error
.
response
.
data
session
(
response
,
navigation
)
Alert
.
alert
(
response
.
msg
);
this
.
setState
({
spinner
:
false
,
})
})
})
let
transIdProps
=
{
trans_id
:
data_order
}
else
{
let
params
=
{
session_id
:
this
.
props
.
session_id
,
outlet_id
:
this
.
props
.
outlet_id
,
address_id
:
this
.
props
.
addressId
,
trans_type
:
this
.
state
.
type
,
order_item
:
this
.
props
.
order_item
,
delivery_charge
:
this
.
props
.
grabamount
,
voucher
:
[{
value
:
this
.
props
.
voucher
.
reward
.
value
,
verification_number
:
this
.
props
.
voucher
.
verification_number
}],
payment
:
{
balance
:
this
.
props
.
route
.
params
.
balanceUsed
,
point
:
this
.
props
.
route
.
params
.
pointused
}
}
}
this
.
props
.
setTransId
(
transIdProps
);
console
.
log
(
params
)
// add API use voucher here
// let param = {
Axios
.
post
(
'https://excelsocrm.ravintoladev.com/crm/v2/transaction/booking'
,
params
).
then
(
res
=>
{
// session_id: this.props.session_id,
let
data_order
=
res
.
data
.
data
.
id
// reward_id: this.props.voucher.id,
// lat: this.props.lat,
this
.
setState
({
// long: this.props.long
spinner
:
false
,
// }
})
let
transIdProps
=
{
// Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/reward/use_reward', param).then(res => {
trans_id
:
data_order
// console.log(res.data)
}
// }).catch(error => {
this
.
props
.
setTransId
(
transIdProps
);
// const { navigation } = this.props
// let response = error.response.data
// add API use voucher here
// session(response, navigation)
// let param = {
// Alert.alert(response.msg);
// session_id: this.props.session_id,
// this.setState({
// reward_id: this.props.voucher.id,
// spinner: false,
// lat: this.props.lat,
// })
// long: this.props.long
// })
// }
Alert
.
alert
(
// Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/reward/use_reward', param).then(res => {
"Berhasil"
,
// console.log(res.data)
"Transaksi sudah berhasil, terimakasih sudah menggunakan excelso untuk ngopi"
,
// }).catch(error => {
[
// const { navigation } = this.props
{
text
:
"OK"
,
onPress
:
()
=>
this
.
orderSuccess
()
}
// let response = error.response.data
// session(response, navigation)
],
// Alert.alert(response.msg);
{
cancelable
:
false
}
// this.setState({
);
// spinner: false,
}).
catch
(
error
=>
{
// })
const
{
navigation
}
=
this
.
props
// })
let
response
=
error
.
response
.
data
session
(
response
,
navigation
)
Alert
.
alert
(
Alert
.
alert
(
response
.
msg
);
"Berhasil"
,
this
.
setState
({
"Transaksi sudah berhasil, terimakasih sudah menggunakan excelso untuk ngopi"
,
spinner
:
false
,
[
{
text
:
"OK"
,
onPress
:
()
=>
this
.
orderSuccess
()
}
],
{
cancelable
:
false
}
);
}).
catch
(
error
=>
{
const
{
navigation
}
=
this
.
props
let
response
=
error
.
response
.
data
session
(
response
,
navigation
)
Alert
.
alert
(
response
.
msg
);
this
.
setState
({
spinner
:
false
,
})
})
})
}
)
}
}
}
orderSuccess
=
()
=>
{
orderSuccess
=
()
=>
{
...
@@ -168,7 +237,14 @@ class MenuConfirmation extends React.Component {
...
@@ -168,7 +237,14 @@ class MenuConfirmation extends React.Component {
<
Text
>
Voucher
Discount
<
/Text
>
<
Text
>
Voucher
Discount
<
/Text
>
<
/View
>
<
/View
>
<
View
style
=
{{
margin
:
10
}}
>
<
View
style
=
{{
margin
:
10
}}
>
<
Text
>
{
this
.
props
.
voucher
.
reward
.
value
}
<
/Text
>
{
this
.
props
.
value_voucher
==
''
?
(
<
Text
>
0
<
/Text
>
)
:
(
<
Text
>
{
this
.
props
.
voucher
.
reward
.
value
}
<
/Text
>
)
}
<
/View
>
<
/View
>
<
/View
>
<
/View
>
<
View
style
=
{{
flexDirection
:
'row'
,
margin
:
10
,
justifyContent
:
'space-between'
}}
>
<
View
style
=
{{
flexDirection
:
'row'
,
margin
:
10
,
justifyContent
:
'space-between'
}}
>
...
@@ -194,11 +270,24 @@ class MenuConfirmation extends React.Component {
...
@@ -194,11 +270,24 @@ class MenuConfirmation extends React.Component {
<
/View
>
<
/View
>
{
this
.
props
.
type_pickup
==
true
?
(
{
this
.
props
.
type_pickup
==
true
?
(
<
View
style
=
{{
margin
:
10
}}
>
<
View
style
=
{{
margin
:
10
}}
>
<
Text
>
{
Math
.
max
(
0
,
this
.
props
.
order_total
-
this
.
props
.
voucher
.
reward
.
value
)}
<
/Text
>
{
this
.
props
.
value_voucher
==
''
?
(
<
Text
>
{
this
.
props
.
order_total
}
<
/Text
>
)
:
(
<
Text
>
{
Math
.
max
(
0
,
this
.
props
.
order_total
-
this
.
props
.
voucher
.
reward
.
value
)}
<
/Text
>
)
}
<
/View
>
<
/View
>
)
:
(
)
:
(
<
View
style
=
{{
margin
:
10
}}
>
<
View
style
=
{{
margin
:
10
}}
>
<
Text
>
{
this
.
props
.
order_total
+
this
.
props
.
grabamount
+
this
.
state
.
diskon
}
<
/Text
>
{
this
.
props
.
value_voucher
==
''
?
(
<
Text
>
{
this
.
props
.
order_total
+
this
.
props
.
grabamount
+
this
.
state
.
diskon
}
<
/Text
>
)
:
(
<
Text
>
{
Math
.
max
(
this
.
props
.
order_total
+
this
.
props
.
grabamount
-
this
.
props
.
voucher
.
reward
.
value
)}
<
/Text
>
)
}
<
/View
>
<
/View
>
)}
)}
...
...
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