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
560b2871
Commit
560b2871
authored
Apr 24, 2020
by
Wahyu Adjie Prasetyo
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://repo.cs.co.id:2222/wahyu/bahanoprek
# Conflicts: # view/ShoppingCart.js
parents
c54fc936
3d11b3d8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
237 additions
and
167 deletions
+237
-167
globalActionType.js
redux/globalActionType.js
+2
-1
globalReducer.js
redux/globalReducer.js
+10
-1
DeliveryAddrees.js
view/DeliveryAddrees.js
+54
-18
MenuSelection.js
view/MenuSelection.js
+13
-22
ShoppingCart.js
view/ShoppingCart.js
+158
-125
No files found.
redux/globalActionType.js
View file @
560b2871
...
...
@@ -24,7 +24,8 @@ const ActionType = {
SET_CHANGE_SHOP
:
'SET_CHANGE_SHOP'
,
ADD_TO_CHART
:
'ADD_TO_CHART'
,
REMOVE_FROM_CHART
:
'REMOVE_FROM_CHART'
,
REDUCE_QUANTITY_ITEM
:
'REDUCE_QUANTITY_ITEM'
REDUCE_QUANTITY_ITEM
:
'REDUCE_QUANTITY_ITEM'
,
SET_ADDRESS
:
'SET_ADDRESS'
}
...
...
redux/globalReducer.js
View file @
560b2871
...
...
@@ -56,7 +56,9 @@ const globalState = {
order_item
:
[],
order_quantity
:
0
,
order_total
:
0
order_total
:
0
,
address
:
''
}
const
rootReducer
=
(
state
=
globalState
,
action
)
=>
{
...
...
@@ -200,6 +202,13 @@ const rootReducer = (state = globalState, action) => {
...
state
}
}
case
ActionType
.
SET_ADDRESS
:{
return
{
...
state
,
address
:
action
.
data
.
address
}
}
case
ActionType
.
SET_LOGOUT
:{
return
{
...
state
,
...
...
view/DeliveryAddrees.js
View file @
560b2871
import
React
from
'react'
;
import
{
View
,
Text
,
StyleSheet
,
Button
,
FlatList
}
from
'react-native'
;
import
{
ScrollView
}
from
'react-native-gesture-handler'
;
import
{
View
,
Text
,
StyleSheet
,
Button
,
FlatList
,
Alert
}
from
'react-native'
;
import
{
ScrollView
,
TouchableOpacity
}
from
'react-native-gesture-handler'
;
import
{
connect
}
from
'react-redux'
;
import
Axios
from
'axios'
;
import
ActionType
from
'../redux/globalActionType'
;
class
DeliveryAddrees
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
data
:[]
data
:
[]
}
}
...
...
@@ -22,7 +23,7 @@ class DeliveryAddrees extends React.Component {
this
.
getAddreess
()
}
getAddreess
(){
getAddreess
()
{
let
params
=
{
session_id
:
this
.
props
.
session_id
,
}
...
...
@@ -50,15 +51,36 @@ class DeliveryAddrees extends React.Component {
})
}
addAdreess
(){
addAdreess
()
{
this
.
props
.
navigation
.
navigate
(
'Address Detail'
,
{
'data'
:
'sample'
,
onChangeAddress
:
this
.
onChangeAddress
})
}
onSave
(
address
)
{
Alert
.
alert
(
''
,
'Apakah anda akan memilih alamat untuk pengiriman ?'
,
[
{
text
:
'OK'
,
onPress
:
()
=>
this
.
props
.
navigation
.
navigate
(
''
)},
],
{
cancelable
:
false
}
)
let
setDataAddress
=
{
address
:
address
}
this
.
props
.
setAddress
(
setDataAddress
);
}
render
()
{
function
Item
({
name
,
description
,
address
})
{
function
Item
({
name
,
description
,
address
})
{
return
(
<
View
style
=
{
styles
.
list_addrees
}
>
<
TouchableOpacity
onPress
=
{()
=>
this
.
onSave
(
address
)}
>
<
View
style
=
{{
margin
:
5
,
}}
>
<
Text
style
=
{{
fontWeight
:
'bold'
,
fontSize
:
20
}}
>
{
name
}
<
/Text
>
<
/View
>
...
...
@@ -68,6 +90,7 @@ class DeliveryAddrees extends React.Component {
<
Text
style
=
{{
margin
:
5
}}
>
Patokan
:
{
description
}
<
/Text
>
<
/TouchableOpacity
>
<
/View
>
);
}
...
...
@@ -84,7 +107,7 @@ class DeliveryAddrees extends React.Component {
<
FlatList
data
=
{
this
.
state
.
data
}
renderItem
=
{({
item
})
=>
<
Item
name
=
{
item
.
name
}
description
=
{
item
.
description
}
address
=
{
item
.
address
}
/>
}
renderItem
=
{({
item
})
=>
<
Item
name
=
{
item
.
name
}
description
=
{
item
.
description
}
address
=
{
item
.
address
}
/>
}
keyExtractor
=
{
item
=>
item
.
id
}
/
>
{
/*
...
...
@@ -144,5 +167,18 @@ const mapStateToProps = (state) => {
}
}
const
mapDispatchToProps
=
(
dispacth
)
=>
{
return
{
setAddress
:
(
setDataAddress
)
=>
dispacth
({
type
:
ActionType
.
SET_ADDRESS
,
data
:
{
address
:
setDataAddress
.
address
,
}
}),
}
}
export
default
connect
(
mapStateToProps
)(
DeliveryAddrees
)
view/MenuSelection.js
View file @
560b2871
...
...
@@ -131,19 +131,21 @@ 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
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
})
}
}
render
()
{
...
...
@@ -152,23 +154,12 @@ class MenuSelection extends React.Component {
<
StatusBar
hidden
=
{
true
}
/
>
<
View
style
=
{{
flex
:
0.7
,
height
:
90
,
flexDirection
:
'row'
,
borderWidth
:
1
,
}}
>
<
FlatList
horizontal
=
{
true
}
style
=
{{
flexDirection
:
'row'
}}
data
=
{
this
.
state
.
list
_c
ategory
}
data
=
{
this
.
state
.
list
C
ategory
}
renderItem
=
{
this
.
renderTabBar
}
keyExtractor
=
{(
item
)
=>
item
.
id
}
/
>
<
/View
>
<
View
style
=
{{
flex
:
3
}}
>
{
/* <SafeAreaView style={styles.container}>
<SectionList
sections={this.state.listMenu}
keyExtractor={item => item.id}
renderItem={({ item }) => (item={item})}
renderSectionHeader={({ section }) => (
<Text >{section.category.name}</Text>
)}
/>
</SafeAreaView> */
}
<
FlatList
data
=
{
this
.
state
.
listMenu
}
renderItem
=
{({
item
,
index
})
=>
(
...
...
view/ShoppingCart.js
View file @
560b2871
This diff is collapsed.
Click to expand it.
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