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
40157d4c
Commit
40157d4c
authored
Apr 28, 2020
by
Wahyu Adjie Prasetyo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ini yang terbaru
parent
e5d203f6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
65 deletions
+101
-65
globalReducer.js
redux/globalReducer.js
+9
-6
Auth.js
view/Auth.js
+1
-0
ItemShopingCart.js
view/ItemShopingCart.js
+1
-1
MenuConfirmation.js
view/MenuConfirmation.js
+2
-1
MenuSelection.js
view/MenuSelection.js
+22
-14
ShoppingCart.js
view/ShoppingCart.js
+66
-43
No files found.
redux/globalReducer.js
View file @
40157d4c
...
@@ -58,7 +58,6 @@ const globalState = {
...
@@ -58,7 +58,6 @@ const globalState = {
order_quantity
:
0
,
order_quantity
:
0
,
order_total
:
0
,
order_total
:
0
,
address
:
''
,
address
:
''
,
addressId
:
''
,
addressId
:
''
,
...
@@ -244,6 +243,9 @@ const rootReducer = (state = globalState, action) => {
...
@@ -244,6 +243,9 @@ 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
...
@@ -355,6 +357,7 @@ const rootReducer = (state = globalState, action) => {
...
@@ -355,6 +357,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
order_item
=
[]
let
order_item
=
[]
if
(
is_exist
)
{
if
(
is_exist
)
{
// update
// update
...
@@ -371,17 +374,17 @@ const rootReducer = (state = globalState, action) => {
...
@@ -371,17 +374,17 @@ const rootReducer = (state = globalState, action) => {
}
}
order_item
=
updated_data
order_item
=
updated_data
let
quantity
=
state
.
order_quantity
let
total
=
parseInt
(
state
.
order_total
)
-
parseInt
(
addedItem
.
price
)
console
.
log
(
"UPDATE "
+
order_item
)
}
}
return
{
return
{
...
state
,
...
state
,
order_item
:
order_item
,
order_item
:
new_items
,
order_quantity
:
quantity
,
order_total
:
total
}
}
}
}
default
:
default
:
return
state
;
return
state
;
}
}
...
...
view/Auth.js
View file @
40157d4c
...
@@ -166,6 +166,7 @@ class Auth extends React.Component {
...
@@ -166,6 +166,7 @@ class Auth extends React.Component {
<
Stack
.
Screen
name
=
"Menu Select"
component
=
{
MenuSelection
}
/
>
<
Stack
.
Screen
name
=
"Menu Select"
component
=
{
MenuSelection
}
/
>
<
Stack
.
Screen
name
=
"Card Info"
component
=
{
CardInfo
}
/
>
<
Stack
.
Screen
name
=
"Card Info"
component
=
{
CardInfo
}
/
>
<
Stack
.
Screen
name
=
"Shopping Cart"
component
=
{
ShoppingCart
}
/
>
<
Stack
.
Screen
name
=
"Shopping Cart"
component
=
{
ShoppingCart
}
/
>
<
Stack
.
Screen
name
=
"Order History"
component
=
{
OrderHistory
}
/
>
<
/
>
<
/
>
)
)
...
...
view/ItemShopingCart.js
View file @
40157d4c
...
@@ -7,7 +7,7 @@ class ItemShoping extends React.Component {
...
@@ -7,7 +7,7 @@ class ItemShoping extends React.Component {
render
()
{
render
()
{
const
{
item
}
=
this
.
props
const
{
item
}
=
this
.
props
return
(
return
(
<
View
style
=
{{
flex
:
1
,
margin
:
10
}}
key
=
{
item
.
id
}
>
<
View
style
=
{{
flex
:
1
,
margin
:
10
}}
key
=
{
item
.
id
}
>
{
/* <Text style={{ fontSize: 20, color: '#c9af6d' }}>{item.name}</Text> */
}
{
/* <Text style={{ fontSize: 20, color: '#c9af6d' }}>{item.name}</Text> */
}
<
View
style
=
{{
flexDirection
:
'row'
}}
>
<
View
style
=
{{
flexDirection
:
'row'
}}
>
...
...
view/MenuConfirmation.js
View file @
40157d4c
...
@@ -44,7 +44,8 @@ class MenuConfirmation extends React.Component {
...
@@ -44,7 +44,8 @@ class MenuConfirmation extends React.Component {
}
}
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
=>
{
Alert
.
alert
(
res
.
data
.
status
,
'Transaksi Berhasil'
)
Alert
.
alert
(
'Transaksi Anda Berhasil'
)
this
.
props
.
navigation
.
navigate
(
'Order History'
);
// console.log(res.data.data)
// console.log(res.data.data)
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
...
...
view/MenuSelection.js
View file @
40157d4c
...
@@ -120,16 +120,19 @@ class MenuSelection extends React.Component {
...
@@ -120,16 +120,19 @@ class MenuSelection extends React.Component {
price
:
parseInt
(
item
.
price
),
price
:
parseInt
(
item
.
price
),
}
}
this
.
props
.
addToChart
(
order_item
)
let
res
=
this
.
props
.
addToChart
(
order_item
)
// console.log('After add : ' + JSON.stringify(res))
const
list_order_item
=
this
.
props
.
order_item
;
const
list_order_item
=
this
.
props
.
order_item
;
let
is_xist
=
list_order_item
.
find
(
row
=>
row
.
id
==
item
.
id
)
let
is_xist
=
list_order_item
.
find
(
row
=>
row
.
id
==
item
.
id
)
let
quantity
=
0
let
quantity
=
1
if
(
is_xist
)
{
if
(
is_xist
)
{
console
.
log
(
is_xist
.
name
+
' Item Sudah ada dengan quantity : '
+
is_xist
.
quantity
)
quantity
=
is_xist
.
quantity
quantity
=
is_xist
.
quantity
}
}
const
listMenu
=
[...
this
.
state
.
listMenu
]
const
listMenu
=
[...
this
.
state
.
listMenu
]
listMenu
[
index
].
qty
=
quantity
listMenu
[
index
].
qty
=
quantity
console
.
log
(
"HASIL : "
+
listMenu
[
index
].
qty
)
console
.
log
(
"HASIL : "
+
listMenu
[
index
].
qty
)
...
@@ -168,18 +171,23 @@ class MenuSelection extends React.Component {
...
@@ -168,18 +171,23 @@ class MenuSelection extends React.Component {
}
}
this
.
props
.
reduceQuantityItem
(
order_item
)
this
.
props
.
reduceQuantityItem
(
order_item
)
let
quantity
=
0
// let quantity = 0
for
(
let
i
=
0
;
i
<
list_order_item
.
length
;
i
++
)
{
console
.
log
(
"INI TEST YA"
+
is_xist
.
quantity
)
const
row
=
list_order_item
[
i
];
const
listMenu
=
[...
this
.
state
.
listMenu
]
if
(
row
.
id
==
item
.
id
)
{
listMenu
[
index
].
qty
=
is_xist
.
quantity
quantity
=
row
.
quantity
this
.
setState
({
}
listMenu
const
listMenu
=
[...
this
.
state
.
listMenu
]
})
listMenu
[
index
].
qty
=
quantity
this
.
setState
({
listMenu
})
// for (let i = 0; i < list_order_item.length; i++) {
}
// const row = list_order_item[i];
// if (row.id == item.id) {
// quantity = row.quantity
// }
// }
}
}
}
}
}
}
...
...
view/ShoppingCart.js
View file @
40157d4c
import
React
from
'react'
;
import
React
from
'react'
;
import
{
View
,
Text
,
TextInput
,
StyleSheet
,
Button
,
TouchableOpacity
,
ScrollView
,
FlatList
,
Image
}
from
'react-native'
;
import
{
View
,
Text
,
TextInput
,
StyleSheet
,
Button
,
TouchableOpacity
,
ScrollView
,
FlatList
,
Image
,
Alert
}
from
'react-native'
;
import
{
connect
}
from
'react-redux'
import
{
connect
}
from
'react-redux'
// import { CheckBox } from 'react-native-elements'
// import { CheckBox } from 'react-native-elements'
import
CheckBox
from
'react-native-check-box'
import
CheckBox
from
'react-native-check-box'
...
@@ -28,7 +28,7 @@ class ShoppingCart extends React.Component {
...
@@ -28,7 +28,7 @@ class ShoppingCart extends React.Component {
diskon
:
0
,
diskon
:
0
,
isDelivery
:
false
,
isDelivery
:
false
,
isPickUp
:
false
,
isPickUp
:
false
,
order_item
:
this
.
props
.
order_item
,
//
order_item: this.props.order_item,
grabtype
:
''
,
grabtype
:
''
,
grabamount
:
''
,
grabamount
:
''
,
grabpickup
:
''
,
grabpickup
:
''
,
...
@@ -58,10 +58,15 @@ class ShoppingCart extends React.Component {
...
@@ -58,10 +58,15 @@ class ShoppingCart extends React.Component {
}
}
}
}
handleMin
(
item
,
index
)
{
handleMin
(
item
,
index
)
{
console
.
log
(
"hai"
)
const
list_order_item
=
this
.
props
.
order_item
;
const
list_order_item
=
this
.
props
.
order_item
;
console
.
log
(
'wakwaw'
)
let
is_xist
=
list_order_item
.
find
(
row
=>
row
.
id
==
item
.
id
)
let
is_xist
=
list_order_item
.
find
(
row
=>
row
.
id
==
item
.
id
)
console
.
log
(
'next'
)
console
.
log
(
JSON
.
stringify
(
is_xist
))
if
(
is_xist
)
{
if
(
is_xist
)
{
if
(
is_xist
.
quantity
!=
0
)
{
if
(
is_xist
.
quantity
!=
0
)
{
const
order_item
=
{
const
order_item
=
{
...
@@ -75,24 +80,46 @@ class ShoppingCart extends React.Component {
...
@@ -75,24 +80,46 @@ class ShoppingCart extends React.Component {
let
quantity
=
0
let
quantity
=
0
for
(
let
i
=
0
;
i
<
list_order_item
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
list_order_item
.
length
;
i
++
)
{
const
row
=
list_order_item
[
i
];
const
row
=
list_order_item
[
i
];
const
qty
=
list_order_item
[
i
];
if
(
row
.
id
==
item
.
id
)
{
if
(
row
.
id
==
item
.
id
)
{
quantity
=
row
.
quantity
quantity
=
row
.
quantity
}
}
}
}
else
if
(
is_xist
.
quantity
===
0
){
}
const
order_item
=
{
id
:
item
.
id
,
name
:
item
.
name
,
price
:
item
.
price
,
if
(
quantity
==
0
)
{
const
order_item
=
{
id
:
item
.
id
,
name
:
item
.
name
,
price
:
item
.
price
,
note
:
item
.
note
,
image
:
item
.
image
,
description
:
item
.
description
,
quantity
:
item
.
quantity
}
this
.
props
.
removeFromChart
(
order_item
)
// this.props.navigation.navigate('Home', {
// screen: 'Menu Select',
// });
}
}
this
.
props
.
reduceQuantityItem
(
order_item
)
}
}
// else if (is_xist.quantity == 0){
// Alert.alert("Apakah anda akan menghapus pesanan ?")
// const order_item = {
// id: item.id,
// name: item.name,
// price: item.price,
// note: item.note,
// image: item.image,
// description: item.description,
// quantity: item.quantity
// }
// this.props.removeFromChart(order_item)
// console.log(order_item)
// }
}
}
}
}
...
@@ -111,7 +138,7 @@ class ShoppingCart extends React.Component {
...
@@ -111,7 +138,7 @@ class ShoppingCart extends React.Component {
const
list_order_item
=
this
.
props
.
order_item
;
const
list_order_item
=
this
.
props
.
order_item
;
let
is_xist
=
list_order_item
.
find
(
row
=>
row
.
id
==
item
.
id
)
let
is_xist
=
list_order_item
.
find
(
row
=>
row
.
id
==
item
.
id
)
console
.
log
(
"INI YA : "
+
is_xist
)
console
.
log
(
"INI YA : "
+
is_xist
)
let
quantity
=
0
let
quantity
=
0
if
(
is_xist
)
{
if
(
is_xist
)
{
...
@@ -161,43 +188,40 @@ class ShoppingCart extends React.Component {
...
@@ -161,43 +188,40 @@ class ShoppingCart extends React.Component {
componentDidMount
()
{
componentDidMount
()
{
this
.
getBalance
()
this
.
getBalance
()
this
.
getRate
()
this
.
getRate
()
console
.
log
(
"INI PROPS"
+
this
.
props
.
address
)
}
}
getRate
()
{
getRate
()
{
let
params
=
{
let
params
=
{
session_id
:
this
.
props
.
session_id
,
session_id
:
this
.
props
.
session_id
,
outlet_id
:
this
.
props
.
outlet_id
,
address_id
:
this
.
props
.
addressId
,
address_id
:
this
.
props
.
addressId
,
order_item
:
this
.
props
.
order_item
order_item
:
this
.
props
.
order_item
}
}
Axios
.
post
(
'https://excelsocrm.ravintoladev.com/crm/v2/delivery/rate'
,
params
).
then
(
res
=>
{
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
))
console
.
log
(
"INI LHO CUY : "
+
JSON
.
stringify
(
res
.
data
.
data
.
outlet_name
))
this
.
setState
({
this
.
setState
({
grabtype
:
res
.
data
.
data
.
quotes
[
0
].
service
.
type
,
grabamount
:
res
.
data
.
data
.
amount
,
grabamount
:
res
.
data
.
data
.
quotes
[
0
].
amount
,
grabdestination
:
res
.
data
.
data
.
outlet_name
,
grabpickup
:
res
.
data
.
data
.
quotes
[
0
].
estimatedTimeline
.
pickup
,
grabdropoff
:
res
.
data
.
data
.
quotes
[
0
].
estimatedTimeline
.
dropoff
,
grabdestination
:
res
.
data
.
data
.
destination
.
address
,
})
})
let
setGrabProps
=
{
let
setGrabProps
=
{
grabtype
:
this
.
state
.
grabtype
,
// grabtype: this.state.grabtype,
grabamount
:
this
.
state
.
grabamount
,
// grabpickup: this.state.grabpickup,
grabpickup
:
this
.
state
.
grabpickup
,
// grabdropoff: this.state.grabdropoff,
grabdropoff
:
this
.
state
.
grabdropoff
,
grabdestination
:
this
.
state
.
grabdestination
,
grabdestination
:
this
.
state
.
grabdestination
,
grabamount
:
this
.
state
.
grabamount
,
}
}
this
.
props
.
setGrab
(
setGrabProps
);
this
.
props
.
setGrab
(
setGrabProps
);
let
setOrdersProps
=
{
let
setOrdersProps
=
{
balanceUsed
:
this
.
state
.
balanceused
,
balanceUsed
:
this
.
state
.
balanceused
,
pointused
:
this
.
state
.
pointsused
,
pointused
:
this
.
state
.
pointsused
,
}
}
this
.
props
.
setOrder
(
setOrdersProps
);
this
.
props
.
setOrder
(
setOrdersProps
);
...
@@ -205,7 +229,6 @@ class ShoppingCart extends React.Component {
...
@@ -205,7 +229,6 @@ class ShoppingCart extends React.Component {
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
log
(
'ini error '
+
error
)
console
.
log
(
'ini error '
+
error
)
})
})
}
}
getBalance
()
{
getBalance
()
{
...
@@ -243,13 +266,13 @@ class ShoppingCart extends React.Component {
...
@@ -243,13 +266,13 @@ class ShoppingCart extends React.Component {
{
{
this
.
state
.
isDelivery
==
true
?
(
this
.
state
.
isDelivery
==
true
?
(
<
Card
style
=
{{
margin
:
5
,
padding
:
10
}}
>
<
Card
style
=
{{
margin
:
5
,
padding
:
10
}}
>
<
Text
style
=
{{
textAlign
:
'center'
}}
>
Ambil
pesanan
kamu
di
<
/Text
>
<
Text
style
=
{{
textAlign
:
'center'
}}
>
Ambil
pesanan
kamu
di
<
/Text
>
<
Text
style
=
{{
textAlign
:
'center'
}}
>
{
this
.
props
.
address
}
<
/Text
>
<
Text
style
=
{{
textAlign
:
'center'
}}
>
{
this
.
props
.
grabdestination
}
<
/Text
>
<
/Card
>
<
/Card
>
)
:
(
)
:
(
<
Card
style
=
{{
margin
:
5
,
padding
:
10
}}
>
<
Card
style
=
{{
margin
:
5
,
padding
:
10
}}
>
<
Text
style
=
{{
textAlign
:
'center'
}}
>
Pesanan
kamu
dikirim
ke
<
/Text
>
<
Text
style
=
{{
textAlign
:
'center'
}}
>
Pesanan
kamu
dikirim
ke
<
/Text
>
<
Text
style
=
{{
textAlign
:
'center'
}}
>
{
this
.
props
.
address
}
<
/Text
>
<
Text
style
=
{{
textAlign
:
'center'
}}
>
{
this
.
props
.
address
}
<
/Text
>
<
/Card
>
<
/Card
>
)
)
...
@@ -263,7 +286,7 @@ class ShoppingCart extends React.Component {
...
@@ -263,7 +286,7 @@ class ShoppingCart extends React.Component {
<
/View
>
<
/View
>
<
View
style
=
{
styles
.
order
}
>
<
View
style
=
{
styles
.
order
}
>
<
FlatList
<
FlatList
data
=
{
this
.
state
.
order_item
}
data
=
{
this
.
props
.
order_item
}
renderItem
=
{({
item
,
index
})
=>
(
renderItem
=
{({
item
,
index
})
=>
(
<
ItemShoping
navigation
=
{
this
.
props
.
navigation
}
<
ItemShoping
navigation
=
{
this
.
props
.
navigation
}
item
=
{
item
}
item
=
{
item
}
...
@@ -457,7 +480,7 @@ class ShoppingCart extends React.Component {
...
@@ -457,7 +480,7 @@ class ShoppingCart extends React.Component {
<
Text
style
=
{{
fontSize
:
35
,
color
:
'#ccb46c'
}}
>
Total
<
/Text
>
<
Text
style
=
{{
fontSize
:
35
,
color
:
'#ccb46c'
}}
>
Total
<
/Text
>
<
/View
>
<
/View
>
<
View
style
=
{{
marginTop
:
15
,
paddingRight
:
30
,
paddingTop
:
10
,
alignItems
:
'flex-end'
}}
>
<
View
style
=
{{
marginTop
:
15
,
paddingRight
:
30
,
paddingTop
:
10
,
alignItems
:
'flex-end'
}}
>
<
Text
style
=
{{
fontSize
:
35
,
color
:
'#ccb46c'
}}
>
{
this
.
props
.
order_total
+
this
.
props
.
grabamount
+
this
.
state
.
diskon
}
<
/Text
>
<
Text
style
=
{{
fontSize
:
35
,
color
:
'#ccb46c'
}}
>
{
this
.
props
.
order_total
+
this
.
props
.
grabamount
+
this
.
state
.
diskon
}
<
/Text
>
<
/View
>
<
/View
>
<
/View
>
<
/View
>
<
View
style
=
{{
flexDirection
:
'row'
,
marginTop
:
10
,
justifyContent
:
'space-between'
}}
>
<
View
style
=
{{
flexDirection
:
'row'
,
marginTop
:
10
,
justifyContent
:
'space-between'
}}
>
...
@@ -635,7 +658,7 @@ const mapDispatchToProps = (dispacth) => {
...
@@ -635,7 +658,7 @@ const mapDispatchToProps = (dispacth) => {
setGrab
:
(
setGrabProps
)
=>
dispacth
({
setGrab
:
(
setGrabProps
)
=>
dispacth
({
type
:
ActionType
.
SET_GRAB
,
type
:
ActionType
.
SET_GRAB
,
data
:
{
data
:
{
grabtype
:
setGrabProps
.
grabtype
,
grabtype
:
setGrabProps
.
grabtype
,
grabamount
:
setGrabProps
.
grabamount
,
grabamount
:
setGrabProps
.
grabamount
,
grabpickup
:
setGrabProps
.
grabpickup
,
grabpickup
:
setGrabProps
.
grabpickup
,
grabdropoff
:
setGrabProps
.
grabdropoff
,
grabdropoff
:
setGrabProps
.
grabdropoff
,
...
@@ -665,8 +688,8 @@ const mapStateToProps = (state) => {
...
@@ -665,8 +688,8 @@ const mapStateToProps = (state) => {
grabtype
:
state
.
grabtype
,
grabtype
:
state
.
grabtype
,
grabamount
:
state
.
grabamount
,
grabamount
:
state
.
grabamount
,
grabpickup
:
state
.
grabpickup
,
grabpickup
:
state
.
grabpickup
,
grabdropoff
:
state
.
grabdropoff
,
grabdropoff
:
state
.
grabdropoff
,
grabdestination
:
state
.
grabdestination
,
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