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 = {
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'
}
......
......@@ -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,
......
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)
......@@ -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_category}
data={this.state.listCategory}
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 }) => (
......
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