Commit 560b2871 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

Merge branch 'master' of ssh://repo.cs.co.id:2222/wahyu/bahanoprek

# Conflicts:
#	view/ShoppingCart.js
parents c54fc936 3d11b3d8
...@@ -24,7 +24,8 @@ const ActionType = { ...@@ -24,7 +24,8 @@ const ActionType = {
SET_CHANGE_SHOP:'SET_CHANGE_SHOP', SET_CHANGE_SHOP:'SET_CHANGE_SHOP',
ADD_TO_CHART:'ADD_TO_CHART', ADD_TO_CHART:'ADD_TO_CHART',
REMOVE_FROM_CHART:'REMOVE_FROM_CHART', REMOVE_FROM_CHART:'REMOVE_FROM_CHART',
REDUCE_QUANTITY_ITEM :'REDUCE_QUANTITY_ITEM' REDUCE_QUANTITY_ITEM :'REDUCE_QUANTITY_ITEM',
SET_ADDRESS :'SET_ADDRESS'
} }
......
...@@ -56,7 +56,9 @@ const globalState = { ...@@ -56,7 +56,9 @@ const globalState = {
order_item: [], order_item: [],
order_quantity: 0, order_quantity: 0,
order_total: 0 order_total: 0,
address:''
} }
const rootReducer = (state = globalState, action) => { const rootReducer = (state = globalState, action) => {
...@@ -200,6 +202,13 @@ const rootReducer = (state = globalState, action) => { ...@@ -200,6 +202,13 @@ const rootReducer = (state = globalState, action) => {
...state ...state
} }
} }
case ActionType.SET_ADDRESS:{
return{
...state,
address: action.data.address
}
}
case ActionType.SET_LOGOUT:{ case ActionType.SET_LOGOUT:{
return{ return{
...state, ...state,
......
import React from 'react'; import React from 'react';
import { View, Text, StyleSheet, Button, FlatList } from 'react-native'; import { View, Text, StyleSheet, Button, FlatList, Alert } from 'react-native';
import { ScrollView } from 'react-native-gesture-handler'; import { ScrollView, TouchableOpacity } from 'react-native-gesture-handler';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import Axios from 'axios'; import Axios from 'axios';
import ActionType from '../redux/globalActionType';
class DeliveryAddrees extends React.Component { class DeliveryAddrees extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
data:[] data: []
} }
} }
componentDidMount() { componentDidMount() {
this.getAddreess() this.getAddreess()
console.log(this.props) console.log(this.props)
} }
onChangeAddress = data => { onChangeAddress = data => {
...@@ -22,7 +23,7 @@ class DeliveryAddrees extends React.Component { ...@@ -22,7 +23,7 @@ class DeliveryAddrees extends React.Component {
this.getAddreess() this.getAddreess()
} }
getAddreess(){ getAddreess() {
let params = { let params = {
session_id: this.props.session_id, session_id: this.props.session_id,
} }
...@@ -50,24 +51,46 @@ class DeliveryAddrees extends React.Component { ...@@ -50,24 +51,46 @@ class DeliveryAddrees extends React.Component {
}) })
} }
addAdreess(){ addAdreess() {
this.props.navigation.navigate('Address Detail', { 'data': 'sample', onChangeAddress: this.onChangeAddress }) 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() { render() {
function Item({ name,description,address }) { function Item({ name, description, address }) {
return ( return (
<View style={styles.list_addrees}> <View style={styles.list_addrees}>
<View style={{ margin: 5, }}> <TouchableOpacity onPress={()=>this.onSave(address)}>
<Text style={{ fontWeight: 'bold', fontSize: 20 }}>{name}</Text> <View style={{ margin: 5, }}>
</View> <Text style={{ fontWeight: 'bold', fontSize: 20 }}>{name}</Text>
<Text style={{ margin: 5 }}> </View>
{address} <Text style={{ margin: 5 }}>
</Text> {address}
<Text style={{ margin: 5 }}> </Text>
Patokan : {description} <Text style={{ margin: 5 }}>
</Text> Patokan : {description}
</Text>
</TouchableOpacity>
</View> </View>
); );
} }
...@@ -84,7 +107,7 @@ class DeliveryAddrees extends React.Component { ...@@ -84,7 +107,7 @@ class DeliveryAddrees extends React.Component {
<FlatList <FlatList
data={this.state.data} 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} keyExtractor={item => item.id}
/> />
{/* {/*
...@@ -144,5 +167,18 @@ const mapStateToProps = (state) => { ...@@ -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) export default connect(mapStateToProps)(DeliveryAddrees)
...@@ -131,18 +131,20 @@ class MenuSelection extends React.Component { ...@@ -131,18 +131,20 @@ class MenuSelection extends React.Component {
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
for (let i = 0; i < list_order_item.length; i++) { if (quantity != 0) {
const row = list_order_item[i]; quantity = quantity - 1
if (row.id == item.id) { for (let i = 0; i < list_order_item.length; i++) {
quantity = row.quantity 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
})
} }
const listMenu = [...this.state.listMenu]
listMenu[index].qty = quantity
this.setState({
listMenu
})
} }
render() { render() {
...@@ -152,23 +154,12 @@ class MenuSelection extends React.Component { ...@@ -152,23 +154,12 @@ class MenuSelection extends React.Component {
<StatusBar hidden={true} /> <StatusBar hidden={true} />
<View style={{ flex: 0.7, height: 90, flexDirection: 'row', borderWidth: 1, }}> <View style={{ flex: 0.7, height: 90, flexDirection: 'row', borderWidth: 1, }}>
<FlatList horizontal={true} style={{ flexDirection: 'row' }} <FlatList horizontal={true} style={{ flexDirection: 'row' }}
data={this.state.list_category} 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 }}>
{/* <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 <FlatList
data={this.state.listMenu} data={this.state.listMenu}
renderItem={({ item, index }) => ( renderItem={({ item, index }) => (
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment