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
b9eba13b
Commit
b9eba13b
authored
Apr 24, 2020
by
Wahyu Adjie Prasetyo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
menu selection
parent
03e4a898
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
27 deletions
+106
-27
Item.js
view/Item.js
+2
-1
MenuSelection.js
view/MenuSelection.js
+34
-21
ShoppingCart.js
view/ShoppingCart.js
+70
-5
No files found.
view/Item.js
View file @
b9eba13b
...
@@ -10,7 +10,8 @@ class Item extends React.Component {
...
@@ -10,7 +10,8 @@ class Item extends React.Component {
<
View
style
=
{{
flex
:
1
,
margin
:
10
}}
>
<
View
style
=
{{
flex
:
1
,
margin
:
10
}}
>
<
ScrollView
ref
=
{
view
=>
this
.
_scrollView
=
view
}
>
<
ScrollView
ref
=
{
view
=>
this
.
_scrollView
=
view
}
>
{
/* <Text style={{ fontSize: 20, color: '#c9af6d' }}>{item.category.name}</Text> */
}
<
Text
style
=
{{
fontSize
:
20
,
color
:
'#c9af6d'
}}
>
{
item
.
category
.
name
}
<
/Text
>
<
View
style
=
{{
flexDirection
:
'row'
}}
>
<
View
style
=
{{
flexDirection
:
'row'
}}
>
<
View
>
<
View
>
<
Image
source
=
{{
uri
:
item
.
image
}}
style
=
{{
height
:
100
,
width
:
100
,
borderRadius
:
5
,
top
:
5
}}
><
/Image
>
<
Image
source
=
{{
uri
:
item
.
image
}}
style
=
{{
height
:
100
,
width
:
100
,
borderRadius
:
5
,
top
:
5
}}
><
/Image
>
...
...
view/MenuSelection.js
View file @
b9eba13b
...
@@ -15,7 +15,7 @@ class MenuSelection extends React.Component {
...
@@ -15,7 +15,7 @@ class MenuSelection extends React.Component {
super
(
props
)
super
(
props
)
this
.
state
=
{
this
.
state
=
{
listCategory
:
[],
listCategory
:
[],
list_category
:[],
list_category
:
[],
listMenu
:
[],
listMenu
:
[],
list_orders
:
[],
list_orders
:
[],
outlet_id
:
''
,
outlet_id
:
''
,
...
@@ -37,34 +37,48 @@ class MenuSelection extends React.Component {
...
@@ -37,34 +37,48 @@ class MenuSelection extends React.Component {
outlet_id
:
"dec1abbb-95d0-46ae-a6cd-2bf306590f15"
outlet_id
:
"dec1abbb-95d0-46ae-a6cd-2bf306590f15"
}
}
Axios
.
post
(
'https://excelsocrm.ravintoladev.com/crm/v2/menu/get_list'
,
params
).
then
(
res
=>
{
Axios
.
post
(
'https://excelsocrm.ravintoladev.com/crm/v2/menu/get_list'
,
params
).
then
(
res
=>
{
let
data
=
res
.
data
.
data
let
data
=
res
.
data
.
data
this
.
setState
({
this
.
setState
({
listCategory
:
data
.
category
,
listCategory
:
data
.
category
,
listMenu
:
data
.
menu
listMenu
:
data
.
menu
})
})
this
.
state
.
listMenu
.
map
((
i
)
=>
(
let
last_category
=
''
i
.
qty
=
0
let
list_menu
=
[]
))
console
.
log
(
"INI DATANYA "
+
JSON
.
stringify
(
data
.
menu
))
}).
catch
(
error
=>
{
for
(
let
row
in
data
.
menu
)
{
let
response
=
error
.
response
.
data
;
if
(
last_category
!=
row
.
category
.
name
)
{
category
=
{
"id"
:
'CATEGORY'
,
"name"
:
row
.
category
.
name
}
list_menu
.
append
(
category
)
list_menu
.
append
(
row
)
last_category
=
row
.
category
.
name
}
else
{
// tampilin item
list_menu
.
append
(
row
)
}
}
})
})
}
}
renderTabBar
=
({
item
})
=>
{
renderTabBar
=
({
item
})
=>
{
return
(
return
(
<
View
style
=
{{
margin
:
10
}}
>
<
View
style
=
{{
margin
:
10
}}
>
<
TouchableOpacity
onPress
=
{()
=>
this
.
scrollToItem
()}
>
<
TouchableOpacity
>
<
Image
style
=
{{
height
:
50
,
width
:
50
,
borderRadius
:
25
}}
source
=
{{
uri
:
item
.
image
}}
/
>
<
Image
style
=
{{
height
:
50
,
width
:
50
,
borderRadius
:
25
}}
source
=
{{
uri
:
item
.
image
}}
/
>
<
Text
>
{
item
.
name
}
<
/Text
>
<
Text
>
{
item
.
name
}
<
/Text
>
<
/TouchableOpacity
>
<
/TouchableOpacity
>
<
/View
>
<
/View
>
)
)
}
}
scroll
(
item
)
{
//
scroll(item) {
this
.
refs
.
_scrollView
.
scrollTo
(
0
);
//
this.refs._scrollView.scrollTo(0);
}
//
}
refresh
()
{
refresh
()
{
this
.
setState
({
isFetching
:
true
},
function
()
{
this
.
getMenuList
()
});
this
.
setState
({
isFetching
:
true
},
function
()
{
this
.
getMenuList
()
});
...
@@ -84,14 +98,14 @@ class MenuSelection extends React.Component {
...
@@ -84,14 +98,14 @@ class MenuSelection extends React.Component {
scrollToItem
=
()
=>
{
scrollToItem
=
()
=>
{
// let newData = []
// let newData = []
// newData.push(this.state.listMenu)
// newData.push(this.state.listMenu)
// console.log("DATA " + JSON.stringify(newData))
// console.log("DATA " + JSON.stringify(newData))
// newData.map((item => {
// newData.map((item => {
// let abc = item[0].category
// let abc = item[0].category
// }))
// }))
this
.
props
.
_scrollView
.
scrollTo
({
y
:
1
*
100
});
this
.
props
.
_scrollView
.
scrollTo
({
y
:
1
*
100
});
}
}
handleAdd
(
item
,
index
)
{
handleAdd
(
item
,
index
)
{
...
@@ -127,7 +141,6 @@ class MenuSelection extends React.Component {
...
@@ -127,7 +141,6 @@ class MenuSelection extends React.Component {
price
:
item
.
price
,
price
:
item
.
price
,
}
}
this
.
props
.
reduceQuantityItem
(
order_item
)
this
.
props
.
reduceQuantityItem
(
order_item
)
const
list_order_item
=
this
.
props
.
order_item
;
const
list_order_item
=
this
.
props
.
order_item
;
let
quantity
=
0
let
quantity
=
0
...
@@ -148,7 +161,7 @@ class MenuSelection extends React.Component {
...
@@ -148,7 +161,7 @@ class MenuSelection extends React.Component {
}
}
render
()
{
render
()
{
return
(
return
(
<
View
style
=
{
styles
.
container
}
>
<
View
style
=
{
styles
.
container
}
>
<
StatusBar
hidden
=
{
true
}
/
>
<
StatusBar
hidden
=
{
true
}
/
>
...
@@ -156,7 +169,7 @@ class MenuSelection extends React.Component {
...
@@ -156,7 +169,7 @@ class MenuSelection extends React.Component {
<
FlatList
horizontal
=
{
true
}
style
=
{{
flexDirection
:
'row'
}}
<
FlatList
horizontal
=
{
true
}
style
=
{{
flexDirection
:
'row'
}}
data
=
{
this
.
state
.
listCategory
}
data
=
{
this
.
state
.
listCategory
}
renderItem
=
{
this
.
renderTabBar
}
renderItem
=
{
this
.
renderTabBar
}
keyExtractor
=
{(
item
)
=>
item
.
id
}
keyExtractor
=
{(
item
)
=>
item
.
id
}
/
>
/
>
<
/View
>
<
/View
>
<
View
style
=
{{
flex
:
3
}}
>
<
View
style
=
{{
flex
:
3
}}
>
...
...
view/ShoppingCart.js
View file @
b9eba13b
...
@@ -51,6 +51,59 @@ class ShoppingCart extends React.Component {
...
@@ -51,6 +51,59 @@ class ShoppingCart extends React.Component {
})
})
}
}
handleAdd
(
item
,
index
)
{
const
order_item
=
{
id
:
item
.
id
,
name
:
item
.
name
,
price
:
item
.
price
,
image
:
item
.
image
}
this
.
props
.
addToChart
(
order_item
)
const
list_order_item
=
this
.
props
.
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
}
}
const
listMenu
=
[...
this
.
state
.
listMenu
]
listMenu
[
index
].
qty
=
quantity
this
.
setState
({
listMenu
})
}
handleMin
(
item
,
index
)
{
const
order_item
=
{
id
:
item
.
id
,
name
:
item
.
name
,
price
:
item
.
price
,
}
this
.
props
.
reduceQuantityItem
(
order_item
)
const
list_order_item
=
this
.
props
.
order_item
;
let
quantity
=
0
if
(
quantity
!=
0
)
{
quantity
=
quantity
-
1
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
({
listMenu
})
}
}
checkedSelection
(
val
)
{
checkedSelection
(
val
)
{
// console.log(val)
// console.log(val)
if
(
val
==
'balance'
)
{
if
(
val
==
'balance'
)
{
...
@@ -132,9 +185,9 @@ class ShoppingCart extends React.Component {
...
@@ -132,9 +185,9 @@ class ShoppingCart extends React.Component {
<
/View
>
<
/View
>
<
View
style
=
{
styles
.
order
}
>
<
View
style
=
{
styles
.
order
}
>
{
this
.
props
.
order_item
.
map
((
item
,
i
)
=>
{
{
this
.
props
.
order_item
.
map
((
item
,
i
ndex
)
=>
{
return
(
return
(
<
View
style
=
{{
flex
:
1
,
margin
:
10
}}
key
=
{
i
}
>
<
View
style
=
{{
flex
:
1
,
margin
:
10
}}
key
=
{
i
ndex
}
>
<
View
style
=
{{
flexDirection
:
'row'
}}
>
<
View
style
=
{{
flexDirection
:
'row'
}}
>
<
View
>
<
View
>
<
Image
source
=
{{
uri
:
item
.
image
}}
style
=
{{
height
:
100
,
width
:
100
,
borderRadius
:
5
,
top
:
5
}}
><
/Image
>
<
Image
source
=
{{
uri
:
item
.
image
}}
style
=
{{
height
:
100
,
width
:
100
,
borderRadius
:
5
,
top
:
5
}}
><
/Image
>
...
@@ -145,7 +198,7 @@ class ShoppingCart extends React.Component {
...
@@ -145,7 +198,7 @@ class ShoppingCart extends React.Component {
<
View
style
=
{{
flexDirection
:
'row'
,
flex
:
1
}}
>
<
View
style
=
{{
flexDirection
:
'row'
,
flex
:
1
}}
>
<
View
style
=
{
styles
.
shadowEdit
}
><
/View
>
<
View
style
=
{
styles
.
shadowEdit
}
><
/View
>
<
View
style
=
{
styles
.
shadowAdd
}
>
<
View
style
=
{
styles
.
shadowAdd
}
>
<
TouchableOpacity
onPress
=
{()
=>
this
.
props
.
handleMin
()}
>
<
TouchableOpacity
onPress
=
{()
=>
this
.
props
.
handleMin
(
item
,
index
)}
>
<
Text
style
=
{{
fontSize
:
20
,
margin
:
2
}}
>
-
<
/Text
>
<
Text
style
=
{{
fontSize
:
20
,
margin
:
2
}}
>
-
<
/Text
>
<
/TouchableOpacity
>
<
/TouchableOpacity
>
<
TextInput
<
TextInput
...
@@ -153,7 +206,7 @@ class ShoppingCart extends React.Component {
...
@@ -153,7 +206,7 @@ class ShoppingCart extends React.Component {
autoCapitalize
=
"none"
>
autoCapitalize
=
"none"
>
{
item
.
quantity
}
{
item
.
quantity
}
<
/TextInput
>
<
/TextInput
>
<
TouchableOpacity
onPress
=
{()
=>
this
.
props
.
handleAdd
()}
>
<
TouchableOpacity
onPress
=
{()
=>
this
.
props
.
handleAdd
(
item
,
index
)}
>
<
Text
style
=
{{
fontSize
:
20
,
margin
:
2
}}
>
+
<
/Text
>
<
Text
style
=
{{
fontSize
:
20
,
margin
:
2
}}
>
+
<
/Text
>
<
/TouchableOpacity
>
<
/TouchableOpacity
>
<
/View
>
<
/View
>
...
@@ -504,6 +557,18 @@ const styles = StyleSheet.create({
...
@@ -504,6 +557,18 @@ const styles = StyleSheet.create({
})
})
const
mapDispatchToProps
=
(
dispacth
)
=>
{
return
{
//REDUCE QUANTITY ITEM
reduceQuantityItem
:
(
item
)
=>
dispacth
({
type
:
ActionType
.
REDUCE_QUANTITY_ITEM
,
data
:
{
item
:
item
}
}),
}
}
const
mapStateToProps
=
(
state
)
=>
{
const
mapStateToProps
=
(
state
)
=>
{
console
.
log
(
state
)
console
.
log
(
state
)
return
{
return
{
...
@@ -518,4 +583,4 @@ const mapStateToProps = (state) => {
...
@@ -518,4 +583,4 @@ const mapStateToProps = (state) => {
}
}
export
default
connect
(
mapStateToProps
)(
ShoppingCart
)
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
)(
ShoppingCart
)
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