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
c03e6b0e
Commit
c03e6b0e
authored
May 13, 2020
by
Trisno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update fix error
parent
c5f58433
Show 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 @
c03e6b0e
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,25 +64,25 @@ const globalState = {
...
@@ -64,25 +64,25 @@ const globalState = {
order_quantity
:
0
,
order_quantity
:
0
,
order_total
:
0
,
order_total
:
0
,
address
:
''
,
address
:
''
,
addressId
:
''
,
addressId
:
''
,
grabtype
:
''
,
grabtype
:
''
,
grabamount
:
''
,
grabamount
:
''
,
grabpickup
:
''
,
grabpickup
:
''
,
grabdropoff
:
''
,
grabdropoff
:
''
,
grabdestination
:
''
,
grabdestination
:
''
,
balanceUsed
:
''
,
balanceUsed
:
''
,
pointused
:
''
,
pointused
:
''
,
trans_id
:
''
,
trans_id
:
''
,
lat
:
''
,
lat
:
''
,
long
:
''
,
long
:
''
,
voucher
:
[],
voucher
:
[],
value_voucher
:
''
value_voucher
:
''
}
}
...
@@ -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
:
{
...
@@ -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
...
@@ -554,7 +554,9 @@ const rootReducer = (state = globalState, action) => {
...
@@ -554,7 +554,9 @@ const rootReducer = (state = globalState, action) => {
grabamount
:
0
,
grabamount
:
0
,
outlet_id
:
''
,
outlet_id
:
''
,
name_outlet
:
''
,
name_outlet
:
''
,
address_id
:
''
address_id
:
''
,
voucher
:
[],
value_voucher
:
''
}
}
}
}
...
...
view/MenuConfirmation.js
View file @
c03e6b0e
...
@@ -48,6 +48,74 @@ class MenuConfirmation extends React.Component {
...
@@ -48,6 +48,74 @@ class MenuConfirmation extends React.Component {
}
}
// console.log(is_pickup)
// console.log(is_pickup)
if
(
this
.
props
.
value
==
''
)
{
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
:
[],
payment
:
{
balance
:
this
.
props
.
route
.
params
.
balanceUsed
,
point
:
this
.
props
.
route
.
params
.
pointused
}
}
console
.
log
(
params
)
Axios
.
post
(
'https://excelsocrm.ravintoladev.com/crm/v2/transaction/booking'
,
params
).
then
(
res
=>
{
let
data_order
=
res
.
data
.
data
.
id
this
.
setState
({
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
,
})
})
}
else
{
let
params
=
{
let
params
=
{
session_id
:
this
.
props
.
session_id
,
session_id
:
this
.
props
.
session_id
,
outlet_id
:
this
.
props
.
outlet_id
,
outlet_id
:
this
.
props
.
outlet_id
,
...
@@ -117,6 +185,7 @@ class MenuConfirmation extends React.Component {
...
@@ -117,6 +185,7 @@ class MenuConfirmation extends React.Component {
})
})
})
})
}
}
}
orderSuccess
=
()
=>
{
orderSuccess
=
()
=>
{
this
.
props
.
setOrderFinish
()
this
.
props
.
setOrderFinish
()
...
@@ -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
}}
>
{
this
.
props
.
value_voucher
==
''
?
(
<
Text
>
0
<
/Text
>
)
:
(
<
Text
>
{
this
.
props
.
voucher
.
reward
.
value
}
<
/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
}}
>
{
this
.
props
.
value_voucher
==
''
?
(
<
Text
>
{
this
.
props
.
order_total
}
<
/Text
>
)
:
(
<
Text
>
{
Math
.
max
(
0
,
this
.
props
.
order_total
-
this
.
props
.
voucher
.
reward
.
value
)}
<
/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
}}
>
{
this
.
props
.
value_voucher
==
''
?
(
<
Text
>
{
this
.
props
.
order_total
+
this
.
props
.
grabamount
+
this
.
state
.
diskon
}
<
/Text
>
<
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