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
1b3ca2f8
Commit
1b3ca2f8
authored
May 06, 2020
by
Wahyu Adjie Prasetyo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
7854ba1a
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
196 additions
and
103 deletions
+196
-103
app.json
app.json
+1
-1
globalActionType.js
redux/globalActionType.js
+2
-1
globalReducer.js
redux/globalReducer.js
+58
-0
Home.js
view/Home.js
+1
-1
Item.js
view/Item.js
+56
-28
ItemShopingCart.js
view/ItemShopingCart.js
+9
-6
MenuSelection.js
view/MenuSelection.js
+56
-66
ShoppingCart.js
view/ShoppingCart.js
+13
-0
No files found.
app.json
View file @
1b3ca2f8
{
"expo"
:
{
"name"
:
"Excelso_update v1
_malam
"
,
"name"
:
"Excelso_update v1
.06062020
"
,
"slug"
:
"excelso-pro"
,
"privacy"
:
"public"
,
"sdkVersion"
:
"36.0.0"
,
...
...
redux/globalActionType.js
View file @
1b3ca2f8
...
...
@@ -33,7 +33,8 @@ const ActionType = {
SET_RECALCULATE
:
'SET_RECALCULATE'
,
SET_ORDER_FINISH
:
'SET_ORDER_FINISH'
,
UPDATE_MENU
:
'UPDATE_MENU'
,
SET_TRANS_ID
:
'SET_TRANS_ID'
SET_TRANS_ID
:
'SET_TRANS_ID'
,
CHANGE_TO_CHART
:
'CHANGE_TO_CHART'
}
export
default
ActionType
;
\ No newline at end of file
redux/globalReducer.js
View file @
1b3ca2f8
...
...
@@ -340,6 +340,64 @@ const rootReducer = (state = globalState, action) => {
}
}
case
ActionType
.
CHANGE_TO_CHART
:
{
let
addedItem
=
action
.
data
.
item
let
is_exist
=
state
.
order_item
.
find
(
item
=>
addedItem
.
id
==
item
.
id
)
let
order_item
=
[]
if
(
is_exist
)
{
// update
updated_data
=
[]
for
(
let
i
=
0
;
i
<
state
.
order_item
.
length
;
i
++
)
{
const
old_data
=
state
.
order_item
[
i
];
const
data
=
old_data
;
if
(
old_data
.
id
==
addedItem
.
id
)
{
update
=
old_data
if
(
update
.
quantity
==
NaN
)
{
update
.
quantity
=
1
}
console
.
log
(
'Update : '
+
JSON
.
stringify
(
update
))
data
=
{
...
old_data
,
...
update
}
}
updated_data
.
push
(
data
)
}
order_item
=
updated_data
}
else
{
// addcd ..
order_item
=
[...
state
.
order_item
]
}
let
quantity
=
state
.
order_quantity
let
menu_item
=
[]
for
(
let
i
=
0
;
i
<
state
.
menu_item
.
length
;
i
++
)
{
const
row
=
state
.
menu_item
[
i
];
if
(
row
.
id
==
addedItem
.
id
)
{
let
is_exist
=
order_item
.
find
(
item
=>
addedItem
.
id
==
item
.
id
)
if
(
is_exist
)
{
row
.
qty
=
is_exist
.
quantity
}
}
menu_item
.
push
(
row
)
}
return
{
...
state
,
menu_item
:
menu_item
,
order_item
:
order_item
,
order_quantity
:
quantity
,
}
}
case
ActionType
.
REDUCE_QUANTITY_ITEM
:
{
let
addedItem
=
action
.
data
.
item
...
...
view/Home.js
View file @
1b3ca2f8
...
...
@@ -284,7 +284,7 @@ class Home extends React.Component {
<
TouchableOpacity
style
=
{
styles
.
submitUpgradePemium
}
activeOpacity
=
{.
5
}
onPress
=
{
this
.
onPress
}
>
<
Text
style
=
{{
textAlign
:
'center'
,
bottom
:
5
,
color
:
'white'
}}
>
TOP
BALANCE
<
/Text
>
<
/TouchableOpacity
>
<
Text
>
APP
.
V2
.
APRIL
<
/Text
>
<
Text
>
UPDATE
SORE
<
/Text
>
<
View
style
=
{{
height
:
60
}}
><
/View
>
<
/View
>
<
/View
>
...
...
view/Item.js
View file @
1b3ca2f8
import
React
from
'react'
;
import
{
View
,
Text
,
StyleSheet
,
ScrollView
,
TouchableOpacity
,
Image
,
TextInput
}
from
'react-native'
;
import
{
connect
}
from
'react-redux'
;
import
ActionType
from
'../redux/globalActionType'
;
class
Item
extends
React
.
Component
{
onChange
(
item
,
value
)
{
console
.
log
()
// const order_item = {
// id: item.id,
// code: item.code,
// name: item.name,
// description: item.description,
// note: 'jangan garing',
// image: item.image,
// quantity: value,
// price: parseInt(item.price),
// }
// let res = this.props.setChangeQuantity(order_item)
}
render
()
{
const
{
item
}
=
this
.
props
// console.log("ini id itemnya "+item.id)
...
...
@@ -12,7 +29,7 @@ class Item extends React.Component {
<
ScrollView
ref
=
{
view
=>
this
.
_scrollView
=
view
}
>
{
item
.
code
==
'CATEGORY'
?
(
<
Text
style
=
{{
fontSize
:
20
,
color
:
'#c9af6d'
}}
>
{
item
.
name
}
<
/Text
>
):
(
)
:
(
<
View
style
=
{{
flexDirection
:
'row'
}}
>
<
View
>
...
...
@@ -29,7 +46,8 @@ class Item extends React.Component {
<
/TouchableOpacity
>
<
TextInput
style
=
{{
height
:
25
,
padding
:
2
,
textAlign
:
'center'
,
margin
:
2
}}
autoCapitalize
=
"none"
>
autoCapitalize
=
"none"
onChangeText
=
{(
value
)
=>
this
.
onChange
(
item
,
value
)}
>
{
item
.
qty
}
<
/TextInput
>
<
TouchableOpacity
onPress
=
{()
=>
this
.
props
.
handleAdd
()}
>
...
...
@@ -99,6 +117,16 @@ const styles = StyleSheet.create({
}
})
const
mapDispatchToProps
=
(
dispacth
)
=>
{
return
{
setChangeQuantity
:
(
item
)
=>
dispacth
({
type
:
ActionType
.
CHANGE_TO_CHART
,
data
:
{
item
:
item
}
}),
}
}
const
mapStateToProps
=
(
state
)
=>
{
// console.log(state)
return
{
...
...
@@ -110,4 +138,4 @@ const mapStateToProps = (state) => {
}
}
export
default
connect
(
mapStateToProps
)(
Item
)
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
)(
Item
)
view/ItemShopingCart.js
View file @
1b3ca2f8
...
...
@@ -3,9 +3,14 @@ import { View, Text, StyleSheet, ScrollView, TouchableOpacity, Image, TextInput
import
{
connect
}
from
'react-redux'
;
class
ItemShoping
extends
React
.
Component
{
constructor
(
props
){
super
(
props
)
}
render
()
{
const
{
item
}
=
this
.
props
this
.
state
=
{
quantity
:
item
.
quantity
}
return
(
<
View
style
=
{{
flex
:
1
,
margin
:
10
}}
key
=
{
item
.
id
}
>
...
...
@@ -23,10 +28,8 @@ class ItemShoping extends React.Component {
<
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
.
quantity
}
<
TextInput
style
=
{{
height
:
25
,
padding
:
2
,
textAlign
:
'center'
,
margin
:
2
}}
onChange
=
{
this
.
props
.
onChange
()}
>
{
this
.
state
.
quantity
}
<
/TextInput
>
<
TouchableOpacity
onPress
=
{()
=>
this
.
props
.
handleAdd
()}
>
<
Text
style
=
{{
fontSize
:
20
,
margin
:
2
}}
>
+
<
/Text
>
...
...
view/MenuSelection.js
View file @
1b3ca2f8
...
...
@@ -24,6 +24,8 @@ class MenuSelection extends React.Component {
order_list
:
[],
list_cart
:
[],
indicator
:
true
,
my_lat
:
0
,
my_long
:
0
}
}
...
...
@@ -36,17 +38,16 @@ class MenuSelection extends React.Component {
indicator
:
true
})
this
.
_getPermissions
()
this
.
getMenuList
()
}
// console.log("INI OUTLET : "+ this.props.outlet_id)
this
.
_unsubscribe
=
this
.
props
.
navigation
.
addListener
(
'focus'
,
()
=>
{
if
(
this
.
props
.
outlet_id
!=
''
)
{
this
.
getMenuList
()
}
else
{
this
.
setState
({
indicator
:
true
indicator
:
true
})
this
.
_getPermissions
()
this
.
getMenuList
()
}
});
}
...
...
@@ -166,9 +167,9 @@ class MenuSelection extends React.Component {
})
}).
catch
(
error
=>
{
const
{
navigation
}
=
this
.
props
const
{
navigation
}
=
this
.
props
let
response
=
error
.
response
.
data
session
(
response
,
navigation
)
session
(
response
,
navigation
)
Alert
.
alert
(
response
.
msg
);
})
...
...
@@ -188,6 +189,12 @@ class MenuSelection extends React.Component {
this
.
setState
({
isFetching
:
true
},
function
()
{
this
.
getMenuList
()
});
}
scrollToItem
=
()
=>
{
this
.
props
.
_scrollView
.
scrollTo
({
y
:
1
*
100
});
}
handleAdd
(
item
,
index
)
{
const
order_item
=
{
...
...
@@ -201,29 +208,42 @@ class MenuSelection extends React.Component {
}
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)
onChange
(
value
){
console
.
log
(
"INI TEXT NYA :"
+
JSON
.
stringify
(
value
))
// 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)
// this.setState({
// listMenu
// })
}
// 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 = {
// id: item.id,
// name: item.name,
// price: item.price,
// }
// this.props.reduceQuantityItem(order_item)
// }
// }
// }
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
=
{
id
:
item
.
id
,
name
:
item
.
name
,
price
:
item
.
price
,
}
this
.
props
.
reduceQuantityItem
(
order_item
)
}
}
}
handleMin
(
item
,
index
)
{
const
list_order_item
=
this
.
props
.
order_item
;
...
...
@@ -274,7 +294,6 @@ class MenuSelection extends React.Component {
item
=
{
item
}
handleAdd
=
{()
=>
this
.
handleAdd
(
item
,
index
)}
handleMin
=
{()
=>
this
.
handleMin
(
item
,
index
)}
onChange
=
{()
=>
this
.
onChange
(
item
,
index
)}
/
>
)}
keyExtractor
=
{
item
=>
item
.
id
}
...
...
@@ -284,7 +303,7 @@ class MenuSelection extends React.Component {
<
View
style
=
{
styles
.
shadow
}
>
{
this
.
state
.
indicator
==
true
?
(
<
ActivityIndicator
style
=
{{
top
:
10
}}
size
=
"large"
color
=
"#c9af6d"
/>
):
(
this
.
state
.
indicator
==
true
?
(
<
ActivityIndicator
style
=
{{
top
:
10
}}
size
=
"large"
color
=
"#c9af6d"
/>
)
:
(
<
View
style
=
{{
flexDirection
:
'row'
,
}}
>
<
Text
style
=
{{
fontSize
:
12
,
margin
:
10
}}
>
Price
Estimation
/
Item
{
this
.
props
.
order_quantity
}
<
/Text
>
...
...
@@ -368,36 +387,7 @@ const mapDispatchToProps = (dispacth) => {
name_outlet
:
OutletChange
.
name_outlet
,
}
}),
setChangeQuantity
:
(
item
)
=>
dispacth
({
type
:
ActionType
.
CHANGE_TO_CHART
,
data
:
{
item
:
item
}
}),
}
}
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
)(
MenuSelection
)
view/ShoppingCart.js
View file @
1b3ca2f8
...
...
@@ -107,6 +107,11 @@ class ShoppingCart extends React.Component {
}
}
onChange
(
params
){
console
.
log
(
params
);
}
handleMin
(
item
,
index
)
{
this
.
setState
({
checkedBalance
:
false
,
...
...
@@ -277,6 +282,9 @@ class ShoppingCart extends React.Component {
}
getRate
()
{
let
params
=
{
...
...
@@ -323,6 +331,10 @@ class ShoppingCart extends React.Component {
}
onChange
(){
}
checkOut
()
{
if
(
this
.
props
.
order_item
.
length
==
0
){
Alert
.
alert
(
'Error'
,
'Please choose your order first'
)
...
...
@@ -399,6 +411,7 @@ class ShoppingCart extends React.Component {
item
=
{
item
}
handleAdd
=
{()
=>
this
.
handleAdd
(
item
,
index
)}
handleMin
=
{()
=>
this
.
handleMin
(
item
,
index
)}
onChange
=
{()
=>
this
.
onChange
(
item
,
index
)}
/
>
)}
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