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
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
Show 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 = {
order_quantity
:
0
,
order_total
:
0
,
address
:
''
,
addressId
:
''
,
...
...
@@ -244,6 +243,9 @@ const rootReducer = (state = globalState, action) => {
session_id
:
action
.
data
.
session_id
,
}
}
case
ActionType
.
ADD_TO_CHART
:
{
let
addedItem
=
action
.
data
.
item
...
...
@@ -355,6 +357,7 @@ const rootReducer = (state = globalState, action) => {
let
addedItem
=
action
.
data
.
item
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
=
[]
if
(
is_exist
)
{
// update
...
...
@@ -371,17 +374,17 @@ const rootReducer = (state = globalState, action) => {
}
order_item
=
updated_data
let
quantity
=
state
.
order_quantity
let
total
=
parseInt
(
state
.
order_total
)
-
parseInt
(
addedItem
.
price
)
console
.
log
(
"UPDATE "
+
order_item
)
}
return
{
...
state
,
order_item
:
order_item
,
order_quantity
:
quantity
,
order_total
:
total
order_item
:
new_items
,
}
}
default
:
return
state
;
}
...
...
view/Auth.js
View file @
40157d4c
...
...
@@ -166,6 +166,7 @@ class Auth extends React.Component {
<
Stack
.
Screen
name
=
"Menu Select"
component
=
{
MenuSelection
}
/
>
<
Stack
.
Screen
name
=
"Card Info"
component
=
{
CardInfo
}
/
>
<
Stack
.
Screen
name
=
"Shopping Cart"
component
=
{
ShoppingCart
}
/
>
<
Stack
.
Screen
name
=
"Order History"
component
=
{
OrderHistory
}
/
>
<
/
>
)
...
...
view/ItemShopingCart.js
View file @
40157d4c
view/MenuConfirmation.js
View file @
40157d4c
...
...
@@ -44,7 +44,8 @@ class MenuConfirmation extends React.Component {
}
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)
}).
catch
(
error
=>
{
...
...
view/MenuSelection.js
View file @
40157d4c
...
...
@@ -120,16 +120,19 @@ class MenuSelection extends React.Component {
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
;
let
is_xist
=
list_order_item
.
find
(
row
=>
row
.
id
==
item
.
id
)
let
quantity
=
0
let
quantity
=
1
if
(
is_xist
)
{
console
.
log
(
is_xist
.
name
+
' Item Sudah ada dengan quantity : '
+
is_xist
.
quantity
)
quantity
=
is_xist
.
quantity
}
const
listMenu
=
[...
this
.
state
.
listMenu
]
listMenu
[
index
].
qty
=
quantity
console
.
log
(
"HASIL : "
+
listMenu
[
index
].
qty
)
...
...
@@ -168,18 +171,23 @@ class MenuSelection extends React.Component {
}
this
.
props
.
reduceQuantityItem
(
order_item
)
let
quantity
=
0
for
(
let
i
=
0
;
i
<
list_order_item
.
length
;
i
++
)
{
const
row
=
list_order_item
[
i
];
if
(
row
.
id
==
item
.
id
)
{
quantity
=
row
.
quantity
}
// let quantity = 0
console
.
log
(
"INI TEST YA"
+
is_xist
.
quantity
)
const
listMenu
=
[...
this
.
state
.
listMenu
]
listMenu
[
index
].
qty
=
quantity
listMenu
[
index
].
qty
=
is_xist
.
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
{
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 { CheckBox } from 'react-native-elements'
import
CheckBox
from
'react-native-check-box'
...
...
@@ -28,7 +28,7 @@ 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
:
''
,
...
...
@@ -58,10 +58,15 @@ class ShoppingCart extends React.Component {
}
}
handleMin
(
item
,
index
)
{
console
.
log
(
"hai"
)
const
list_order_item
=
this
.
props
.
order_item
;
console
.
log
(
'wakwaw'
)
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
.
quantity
!=
0
)
{
const
order_item
=
{
...
...
@@ -75,25 +80,47 @@ class ShoppingCart extends React.Component {
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
}
}
}
else
if
(
is_xist
.
quantity
===
0
){
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
.
reduceQuantityItem
(
order_item
)
this
.
props
.
removeFromChart
(
order_item
)
// this.props.navigation.navigate('Home', {
// screen: 'Menu Select',
// });
}
}
// 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)
// }
}
}
handleAdd
(
item
,
index
)
{
...
...
@@ -111,7 +138,7 @@ class ShoppingCart extends React.Component {
const
list_order_item
=
this
.
props
.
order_item
;
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
if
(
is_xist
)
{
...
...
@@ -162,35 +189,32 @@ class ShoppingCart extends React.Component {
componentDidMount
()
{
this
.
getBalance
()
this
.
getRate
()
console
.
log
(
"INI PROPS"
+
this
.
props
.
address
)
}
getRate
()
{
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
))
console
.
log
(
"INI LHO CUY : "
+
JSON
.
stringify
(
res
.
data
.
data
.
outlet_name
))
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
,
grabamount
:
res
.
data
.
data
.
amount
,
grabdestination
:
res
.
data
.
data
.
outlet_name
,
})
let
setGrabProps
=
{
grabtype
:
this
.
state
.
grabtype
,
grabamount
:
this
.
state
.
grabamount
,
grabpickup
:
this
.
state
.
grabpickup
,
grabdropoff
:
this
.
state
.
grabdropoff
,
// grabtype: this.state.grabtype,
// grabpickup: this.state.grabpickup,
// grabdropoff: this.state.grabdropoff,
grabdestination
:
this
.
state
.
grabdestination
,
grabamount
:
this
.
state
.
grabamount
,
}
this
.
props
.
setGrab
(
setGrabProps
);
...
...
@@ -205,7 +229,6 @@ class ShoppingCart extends React.Component {
}).
catch
(
error
=>
{
console
.
log
(
'ini error '
+
error
)
})
}
getBalance
()
{
...
...
@@ -244,7 +267,7 @@ class ShoppingCart extends React.Component {
this
.
state
.
isDelivery
==
true
?
(
<
Card
style
=
{{
margin
:
5
,
padding
:
10
}}
>
<
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
>
)
:
(
...
...
@@ -263,7 +286,7 @@ class ShoppingCart extends React.Component {
<
/View
>
<
View
style
=
{
styles
.
order
}
>
<
FlatList
data
=
{
this
.
state
.
order_item
}
data
=
{
this
.
props
.
order_item
}
renderItem
=
{({
item
,
index
})
=>
(
<
ItemShoping
navigation
=
{
this
.
props
.
navigation
}
item
=
{
item
}
...
...
@@ -457,7 +480,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
+
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
style
=
{{
flexDirection
:
'row'
,
marginTop
:
10
,
justifyContent
:
'space-between'
}}
>
...
...
@@ -665,8 +688,8 @@ const mapStateToProps = (state) => {
grabtype
:
state
.
grabtype
,
grabamount
:
state
.
grabamount
,
grabpickup
:
state
.
grabpickup
,
grabdropoff
:
state
.
grabdropoff
,
grabdestination
:
state
.
grabdestination
,
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