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
b5e5ea24
Commit
b5e5ea24
authored
Apr 24, 2020
by
Wahyu Adjie Prasetyo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change
parent
ddc5c424
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
47 deletions
+65
-47
globalReducer.js
redux/globalReducer.js
+1
-0
Item.js
view/Item.js
+35
-32
MenuSelection.js
view/MenuSelection.js
+29
-15
No files found.
redux/globalReducer.js
View file @
b5e5ea24
...
...
@@ -276,6 +276,7 @@ const rootReducer = (state = globalState, action) => {
if
(
update
.
quantity
==
NaN
){
update
.
quantity
=
1
}
update
.
quantity
-=
1
console
.
log
(
'Update : '
+
JSON
.
stringify
(
update
))
data
=
{...
old_data
,
...
update
}
...
...
view/Item.js
View file @
b5e5ea24
...
...
@@ -4,14 +4,15 @@ import { connect } from 'react-redux';
class
Item
extends
React
.
Component
{
render
()
{
const
{
item
}
=
this
.
props
// console.log('ini props nya item : ' + JSON.stringify(item))
const
{
description
,
name
,
image
,
price
,
qty
,
}
=
item
console
.
log
(
"ini id itemnya "
+
item
.
id
)
return
(
<
View
style
=
{{
flex
:
1
,
margin
:
10
}}
>
<
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
>
):
(
<
Text
style
=
{{
fontSize
:
20
,
color
:
'#c9af6d'
}}
>
{
item
.
category
.
name
}
<
/Text
>
<
View
style
=
{{
flexDirection
:
'row'
}}
>
<
View
>
<
Image
source
=
{{
uri
:
item
.
image
}}
style
=
{{
height
:
100
,
width
:
100
,
borderRadius
:
5
,
top
:
5
}}
><
/Image
>
...
...
@@ -26,7 +27,7 @@ class Item extends React.Component {
<
Text
style
=
{{
fontSize
:
20
,
margin
:
2
}}
>
-
<
/Text
>
<
/TouchableOpacity
>
<
TextInput
style
=
{{
height
:
25
,
padding
:
2
,
textAlign
:
'center'
,
margin
:
2
}}
style
=
{{
height
:
25
,
padding
:
2
,
textAlign
:
'center'
,
margin
:
2
}}
autoCapitalize
=
"none"
>
{
item
.
qty
}
<
/TextInput
>
...
...
@@ -37,6 +38,8 @@ class Item extends React.Component {
<
/View
>
<
/View
>
<
/View
>
)}
<
/ScrollView
>
<
/View
>
)
...
...
@@ -100,10 +103,10 @@ const mapStateToProps = (state) => {
return
{
session_id
:
state
.
session_id
,
outlet_id
:
state
.
outlet_id
,
order_quantity
:
state
.
order_quantity
,
order_total
:
state
.
order_total
,
order_quantity
:
state
.
order_quantity
,
order_total
:
state
.
order_total
,
quantity
:
state
.
quantity
,
}
}
}
export
default
connect
(
mapStateToProps
)(
Item
)
view/MenuSelection.js
View file @
b5e5ea24
...
...
@@ -44,27 +44,39 @@ class MenuSelection extends React.Component {
listMenu
:
data
.
menu
})
let
last_category
=
''
let
list_menu
=
[]
console
.
log
(
"INI DATANYA "
+
JSON
.
stringify
(
data
.
menu
))
for
(
let
row
in
data
.
menu
)
{
for
(
let
i
=
0
;
i
<
data
.
menu
.
length
;
i
++
)
{
const
row
=
data
.
menu
[
i
];
if
(
last_category
!=
row
.
category
.
name
)
{
category
=
{
"id"
:
'CATEGORY'
,
"name"
:
row
.
category
.
name
let
category
=
{
"id"
:
row
.
category
.
id
,
"name"
:
row
.
category
.
name
,
"code"
:
"CATEGORY"
}
list_menu
.
append
(
category
)
list_menu
.
append
(
row
)
list_menu
.
push
(
category
)
list_menu
.
push
(
row
)
last_category
=
row
.
category
.
name
}
else
{
// tampilin item
list_menu
.
append
(
row
)
list_menu
.
push
(
row
)
}
}
this
.
state
.
listMenu
.
map
((
i
=>
{
i
.
qty
=
0
}))
console
.
log
(
'After : '
+
JSON
.
stringify
(
list_menu
))
this
.
setState
({
listMenu
:
list_menu
})
})
}
renderTabBar
=
({
item
})
=>
{
return
(
...
...
@@ -144,14 +156,14 @@ class MenuSelection extends React.Component {
this
.
props
.
reduceQuantityItem
(
order_item
)
const
list_order_item
=
this
.
props
.
order_item
;
let
quantity
=
0
if
(
quantity
!=
0
)
{
quantity
=
quantity
-
1
if
(
item
.
qty
==
0
)
{
item
.
qty
=
0
}
else
{
for
(
let
i
=
0
;
i
<
list_order_item
.
length
;
i
++
)
{
const
row
=
list_order_item
[
i
];
if
(
row
.
id
==
item
.
id
)
{
quantity
=
row
.
quantity
}
}
const
listMenu
=
[...
this
.
state
.
listMenu
]
listMenu
[
index
].
qty
=
quantity
this
.
setState
({
...
...
@@ -160,13 +172,15 @@ class MenuSelection extends React.Component {
}
}
render
()
{
}
render
()
{
return
(
<
View
style
=
{
styles
.
container
}
>
<
StatusBar
hidden
=
{
true
}
/
>
<
View
style
=
{{
flex
:
0.7
,
height
:
90
,
flexDirection
:
'row'
,
borderWidth
:
1
,
}}
>
<
FlatList
horizontal
=
{
true
}
style
=
{{
flexDirection
:
'row'
}}
showsHorizontalScrollIndicator
=
{
false
}
data
=
{
this
.
state
.
listCategory
}
renderItem
=
{
this
.
renderTabBar
}
keyExtractor
=
{(
item
)
=>
item
.
id
}
...
...
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