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
d47eebb0
Commit
d47eebb0
authored
Apr 27, 2020
by
Wahyu Adjie Prasetyo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ini perubahan menu selection
parent
03cdc02e
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
306 additions
and
130 deletions
+306
-130
globalReducer.js
redux/globalReducer.js
+111
-93
Item.js
view/Item.js
+1
-0
ItemShopingCart.js
view/ItemShopingCart.js
+114
-0
MenuSelection.js
view/MenuSelection.js
+80
-37
No files found.
redux/globalReducer.js
View file @
d47eebb0
This diff is collapsed.
Click to expand it.
view/Item.js
View file @
d47eebb0
import
React
from
'react'
;
import
React
from
'react'
;
import
{
View
,
Text
,
StyleSheet
,
ScrollView
,
TouchableOpacity
,
Image
,
TextInput
}
from
'react-native'
;
import
{
View
,
Text
,
StyleSheet
,
ScrollView
,
TouchableOpacity
,
Image
,
TextInput
}
from
'react-native'
;
import
{
connect
}
from
'react-redux'
;
import
{
connect
}
from
'react-redux'
;
class
Item
extends
React
.
Component
{
class
Item
extends
React
.
Component
{
render
()
{
render
()
{
const
{
item
}
=
this
.
props
const
{
item
}
=
this
.
props
...
...
view/ItemShopingCart.js
0 → 100644
View file @
d47eebb0
import
React
from
'react'
;
import
{
View
,
Text
,
StyleSheet
,
ScrollView
,
TouchableOpacity
,
Image
,
TextInput
}
from
'react-native'
;
import
{
connect
}
from
'react-redux'
;
class
ItemShoping
extends
React
.
Component
{
render
()
{
const
{
item
}
=
this
.
props
console
.
log
(
"ini id itemnya "
+
item
.
id
)
return
(
<
View
style
=
{{
flex
:
1
,
margin
:
10
}}
key
=
{
item
.
id
}
ref
=
{
this
.
props
.
_scrollView
}
>
<
ScrollView
ref
=
{
view
=>
this
.
_scrollView
=
view
}
>
{
item
.
code
==
'CATEGORY'
?
(
<
Text
style
=
{{
fontSize
:
20
,
color
:
'#c9af6d'
}}
>
{
item
.
name
}
<
/Text
>
):
(
<
View
style
=
{{
flexDirection
:
'row'
}}
>
<
View
>
<
Image
source
=
{{
uri
:
item
.
image
}}
style
=
{{
height
:
100
,
width
:
100
,
borderRadius
:
5
,
top
:
5
}}
><
/Image
>
<
/View
>
<
View
>
<
Text
style
=
{{
fontSize
:
20
,
margin
:
5
,
marginRight
:
10
,
fontWeight
:
'bold'
}}
>
{
item
.
name
}
<
/Text
>
<
Text
style
=
{{
fontSize
:
15
,
margin
:
5
,
marginRight
:
10
}}
>
Rp
.
{
item
.
price
}
<
/Text
>
<
View
style
=
{{
flexDirection
:
'row'
,
flex
:
1
}}
>
<
View
style
=
{
styles
.
shadowEdit
}
><
/View
>
<
View
style
=
{
styles
.
shadowAdd
}
>
<
TouchableOpacity
onPress
=
{()
=>
this
.
props
.
handleMin
()}
>
<
Text
style
=
{{
fontSize
:
20
,
margin
:
2
}}
>
-
<
/Text
>
<
/TouchableOpacity
>
<
TextInput
style
=
{{
height
:
25
,
padding
:
2
,
textAlign
:
'center'
,
margin
:
2
}}
autoCapitalize
=
"none"
>
{
item
.
qty
}
<
/TextInput
>
<
TouchableOpacity
onPress
=
{()
=>
this
.
props
.
handleAdd
()}
>
<
Text
style
=
{{
fontSize
:
20
,
margin
:
2
}}
>
+
<
/Text
>
<
/TouchableOpacity
>
<
/View
>
<
/View
>
<
/View
>
<
/View
>
)}
<
/ScrollView
>
<
/View
>
)
}
}
const
styles
=
StyleSheet
.
create
({
shadowEdit
:
{
height
:
30
,
width
:
25
,
borderWidth
:
1
,
borderRadius
:
2
,
borderColor
:
'#ddd'
,
borderBottomWidth
:
0
,
shadowColor
:
'#000'
,
shadowOffset
:
{
width
:
0
,
height
:
2
},
shadowOpacity
:
0.8
,
shadowRadius
:
2
,
elevation
:
1
,
marginLeft
:
5
,
marginRight
:
5
,
marginTop
:
10
,
},
shadowAdd
:
{
height
:
30
,
width
:
75
,
borderWidth
:
1
,
borderRadius
:
2
,
borderColor
:
'#ddd'
,
borderBottomWidth
:
0
,
shadowColor
:
'#000'
,
shadowOffset
:
{
width
:
0
,
height
:
2
},
shadowOpacity
:
0.8
,
shadowRadius
:
2
,
elevation
:
1
,
marginLeft
:
5
,
marginRight
:
5
,
marginTop
:
10
,
flexDirection
:
'row'
},
shadowMin
:
{
height
:
20
,
width
:
20
,
borderWidth
:
1
,
borderRadius
:
2
,
borderColor
:
'#ddd'
,
borderBottomWidth
:
0
,
shadowColor
:
'#000'
,
shadowOffset
:
{
width
:
0
,
height
:
2
},
shadowOpacity
:
0.8
,
shadowRadius
:
2
,
elevation
:
1
,
marginLeft
:
5
,
marginRight
:
5
,
marginTop
:
10
,
}
})
const
mapStateToProps
=
(
state
)
=>
{
console
.
log
(
state
)
return
{
session_id
:
state
.
session_id
,
outlet_id
:
state
.
outlet_id
,
order_quantity
:
state
.
order_quantity
,
order_total
:
state
.
order_total
,
quantity
:
state
.
quantity
,
}
}
export
default
connect
(
mapStateToProps
)(
Item
)
view/MenuSelection.js
View file @
d47eebb0
...
@@ -53,11 +53,19 @@ class MenuSelection extends React.Component {
...
@@ -53,11 +53,19 @@ class MenuSelection extends React.Component {
const
row
=
data
.
menu
[
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
)
{
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
)
...
@@ -67,12 +75,12 @@ class MenuSelection extends React.Component {
...
@@ -67,12 +75,12 @@ class MenuSelection extends React.Component {
}
}
}
}
this
.
state
.
listMenu
.
map
((
i
=>
{
//
this.state.listMenu.map((i => {
i
.
qty
=
0
// i.qty =
0
}))
//
}))
console
.
log
(
'After : '
+
JSON
.
stringify
(
list_menu
))
console
.
log
(
'After : '
+
JSON
.
stringify
(
list_menu
))
this
.
setState
({
this
.
setState
({
listMenu
:
list_menu
listMenu
:
list_menu
})
})
})
})
...
@@ -121,6 +129,7 @@ class MenuSelection extends React.Component {
...
@@ -121,6 +129,7 @@ class MenuSelection extends React.Component {
}
}
handleAdd
(
item
,
index
)
{
handleAdd
(
item
,
index
)
{
console
.
log
(
'TAMPILIN NIH'
)
const
order_item
=
{
const
order_item
=
{
id
:
item
.
id
,
id
:
item
.
id
,
name
:
item
.
name
,
name
:
item
.
name
,
...
@@ -130,23 +139,36 @@ class MenuSelection extends React.Component {
...
@@ -130,23 +139,36 @@ class MenuSelection extends React.Component {
this
.
props
.
addToChart
(
order_item
)
this
.
props
.
addToChart
(
order_item
)
// console.log("ORDER ITEM " + this.props.order_item)
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
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];
if
(
row
.
id
==
item
.
id
)
{
// if (row.id == item.id) {
quantity
=
row
.
quantity
// quantity = row.quantity
}
// }
// }
if
(
is_xist
)
{
quantity
=
is_xist
.
quantity
}
}
const
listMenu
=
[...
this
.
state
.
listMenu
]
const
listMenu
=
[...
this
.
state
.
listMenu
]
// console.log("INI COY YYYY QUANTITY " + quantity)
listMenu
[
index
].
qty
=
quantity
listMenu
[
index
].
qty
=
quantity
this
.
setState
({
this
.
setState
({
listMenu
listMenu
})
})
}
}
handleMin
(
item
,
index
)
{
clearNegatif
(
item
,
index
){
const
list_order_item
=
this
.
props
.
order_item
;
for
(
let
i
=
0
;
i
<
list_order_item
.
length
;
index
++
)
{
const
row
=
list_order_item
[
i
];
if
(
row
.
quantity
!==
0
)
{
const
order_item
=
{
const
order_item
=
{
id
:
item
.
id
,
id
:
item
.
id
,
name
:
item
.
name
,
name
:
item
.
name
,
...
@@ -154,13 +176,29 @@ class MenuSelection extends React.Component {
...
@@ -154,13 +176,29 @@ class MenuSelection extends React.Component {
}
}
this
.
props
.
reduceQuantityItem
(
order_item
)
this
.
props
.
reduceQuantityItem
(
order_item
)
}
}
}
handleMin
(
item
,
index
)
{
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
)
if
(
is_xist
)
{
if
(
is_xist
.
quantity
!=
0
)
{
const
order_item
=
{
id
:
item
.
id
,
name
:
item
.
name
,
price
:
item
.
price
,
}
this
.
props
.
reduceQuantityItem
(
order_item
)
let
quantity
=
0
let
quantity
=
0
if
(
item
.
qty
==
0
)
{
item
.
qty
=
0
}
else
{
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
}
}
...
@@ -171,6 +209,10 @@ class MenuSelection extends React.Component {
...
@@ -171,6 +209,10 @@ class MenuSelection extends React.Component {
})
})
}
}
}
}
}
// this.clearNegatif(item,index)
// ini buat update list menu
}
}
...
@@ -188,6 +230,7 @@ class MenuSelection extends React.Component {
...
@@ -188,6 +230,7 @@ class MenuSelection extends React.Component {
<
/View
>
<
/View
>
<
View
style
=
{{
flex
:
3
}}
>
<
View
style
=
{{
flex
:
3
}}
>
<
FlatList
<
FlatList
data
=
{
this
.
state
.
listMenu
}
data
=
{
this
.
state
.
listMenu
}
renderItem
=
{({
item
,
index
})
=>
(
renderItem
=
{({
item
,
index
})
=>
(
<
Item
navigation
=
{
this
.
props
.
navigation
}
<
Item
navigation
=
{
this
.
props
.
navigation
}
...
...
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