Commit fd26ccc5 authored by Trisno's avatar Trisno

fix bug improvement

parent 57f11248
...@@ -10,14 +10,14 @@ class DeliveryAddrees extends React.Component { ...@@ -10,14 +10,14 @@ class DeliveryAddrees extends React.Component {
super(props) super(props)
this.state = { this.state = {
data: [], data: [],
outlet_id:'', outlet_id: '',
grabamount:'' grabamount: ''
} }
} }
componentDidMount() { componentDidMount() {
this.getAddreess() this.getAddreess()
console.log("INI ADDRESS ID : "+ this.props.addressId) console.log("INI ADDRESS ID : " + this.props.addressId)
} }
onChangeAddress = data => { onChangeAddress = data => {
...@@ -72,15 +72,20 @@ class DeliveryAddrees extends React.Component { ...@@ -72,15 +72,20 @@ class DeliveryAddrees extends React.Component {
grabamount: this.state.grabamount, grabamount: this.state.grabamount,
} }
this.props.setGrab(setGrabProps); let OutletChange = {
outlet_id: res.data.data.outlet_id,
name_outlet: res.data.data.outlet_name,
}
this.props.setGrab(setGrabProps);
this.props.setChangeOutletProps(OutletChange);
console.log("INI SUKSES RESPONNYA ") console.log("INI SUKSES RESPONNYA ")
let setOrdersProps = { // let setOrdersProps = {
balanceUsed: this.state.balanceused, // balanceUsed: this.state.balanceused,
pointused: this.state.pointsused, // pointused: this.state.pointsused,
} // }
this.props.setOrder(setOrdersProps); // this.props.setOrder(setOrdersProps);
}).catch(error => { }).catch(error => {
...@@ -93,40 +98,52 @@ class DeliveryAddrees extends React.Component { ...@@ -93,40 +98,52 @@ class DeliveryAddrees extends React.Component {
} }
onSave(address,id) { onSave(address, id) {
let setDataAddress = { let setDataAddress = {
address : address, address: address,
addressId :id addressId: id
} }
this.props.setAddress(setDataAddress); this.props.setAddress(setDataAddress);
let recalculateProps = { this.getRate()
order_total: 0,
order_quantity:0, // console.log(this.props)
order_item:[]
if (this.props.route.params.from == 'shoppingCart') {
this.props.navigation.navigate('Shopping Cart')
} else {
this.props.navigation.navigate("Menu Select")
} }
this.props.setRecalculate(recalculateProps)
Alert.alert(
'',
'Apakah anda akan memilih alamat untuk pengiriman ?',
[
{text: 'OK', onPress: () => this.props.navigation.navigate("Menu Select") },
], // let recalculateProps = {
{ cancelable: false } // order_total: 0,
) // order_quantity:0,
// order_item:[]
// }
// this.props.setRecalculate(recalculateProps)
// Alert.alert(
// '',
// 'Apakah anda akan memilih alamat untuk pengiriman ?',
// [
// {text: 'OK', onPress: () => this.props.navigation.navigate("Menu Select") },
// ],
// { cancelable: false }
// )
} }
renderItem = ({item})=>{ renderItem = ({ item }) => {
return ( return (
<View style={styles.list_addrees}> <View style={styles.list_addrees}>
<TouchableOpacity onPress={()=> this.onSave(item.address,item.id)}> <TouchableOpacity onPress={() => this.onSave(item.address, item.id)}>
<View style={{ margin: 5, }}> <View style={{ margin: 5, }}>
<Text style={{ fontWeight: 'bold', fontSize: 20 }}>{item.name}</Text> <Text style={{ fontWeight: 'bold', fontSize: 20 }}>{item.name}</Text>
</View> </View>
...@@ -200,14 +217,22 @@ const mapStateToProps = (state) => { ...@@ -200,14 +217,22 @@ const mapStateToProps = (state) => {
return { return {
session_id: state.session_id, session_id: state.session_id,
addressId : state.addressId addressId: state.addressId
} }
} }
const mapDispatchToProps = (dispacth) => { const mapDispatchToProps = (dispacth) => {
return { return {
setChangeOutletProps: (OutletChange) => dispacth({
type: ActionType.SET_CHANGE_OUTLET,
data: {
outlet_id: OutletChange.outlet_id,
name_outlet: OutletChange.name_outlet,
}
}),
setAddress: (setDataAddress) => dispacth({ setAddress: (setDataAddress) => dispacth({
type: ActionType.SET_ADDRESS, type: ActionType.SET_ADDRESS,
data: { data: {
...@@ -230,7 +255,7 @@ const mapDispatchToProps = (dispacth) => { ...@@ -230,7 +255,7 @@ const mapDispatchToProps = (dispacth) => {
type: ActionType.SET_RECALCULATE, type: ActionType.SET_RECALCULATE,
data: { data: {
order_total : recalculateProps.order_total, order_total: recalculateProps.order_total,
order_quantity: recalculateProps.order_quantity, order_quantity: recalculateProps.order_quantity,
order_item: recalculateProps.order_item order_item: recalculateProps.order_item
...@@ -239,5 +264,5 @@ const mapDispatchToProps = (dispacth) => { ...@@ -239,5 +264,5 @@ const mapDispatchToProps = (dispacth) => {
} }
} }
export default connect(mapStateToProps,mapDispatchToProps)(DeliveryAddrees) export default connect(mapStateToProps, mapDispatchToProps)(DeliveryAddrees)
...@@ -137,7 +137,7 @@ class Home extends React.Component { ...@@ -137,7 +137,7 @@ class Home extends React.Component {
type_pickup: true, type_pickup: true,
} }
this.props.setTypePickup(typeProps); this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Pickup Name'); this.props.navigation.navigate('Pickup Name', {from : 'home'});
} }
_order(){ _order(){
...@@ -145,7 +145,7 @@ class Home extends React.Component { ...@@ -145,7 +145,7 @@ class Home extends React.Component {
type_pickup: false, type_pickup: false,
} }
this.props.setTypePickup(typeProps); this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Delivery Address'); this.props.navigation.navigate('Delivery Address', {from : 'home'});
} }
......
...@@ -75,15 +75,20 @@ class PickupName extends React.Component { ...@@ -75,15 +75,20 @@ class PickupName extends React.Component {
type_pickup: true, type_pickup: true,
} }
let recalculateProps = { // let recalculateProps = {
order_total: 0, // order_total: 0,
order_quantity:0, // order_quantity:0,
order_item:[] // order_item:[]
} // }
this.props.setRecalculate(recalculateProps) // this.props.setRecalculate(recalculateProps)
this.props.setChangeOutletProps(OutletChange); this.props.setChangeOutletProps(OutletChange);
this.props.setTypePickup(typeProps); this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Menu Select')
if (this.props.route.params.from == 'shoppingCart') {
this.props.navigation.navigate('Shopping Cart')
} else {
this.props.navigation.navigate("Menu Select")
}
} }
getOutlet() { getOutlet() {
......
...@@ -31,9 +31,9 @@ class ShoppingCart extends React.Component { ...@@ -31,9 +31,9 @@ class ShoppingCart extends React.Component {
grabpickup: '', grabpickup: '',
grabdropoff: '', grabdropoff: '',
grabdestination: '', grabdestination: '',
my_lat:0, my_lat: 0,
my_long:0, my_long: 0,
indicator:true, indicator: true,
// dummyBalance : 155000, // dummyBalance : 155000,
// dummyPoint : 20000 // dummyPoint : 20000
...@@ -60,6 +60,7 @@ class ShoppingCart extends React.Component { ...@@ -60,6 +60,7 @@ class ShoppingCart extends React.Component {
pointsused: 0, pointsused: 0,
balanceused: 0 balanceused: 0
}) })
this.props.navigation.navigate("Delivery Address", {from : 'shoppingCart'})
} else { } else {
let typeProps = { let typeProps = {
type_pickup: true, type_pickup: true,
...@@ -72,6 +73,7 @@ class ShoppingCart extends React.Component { ...@@ -72,6 +73,7 @@ class ShoppingCart extends React.Component {
pointsused: 0, pointsused: 0,
balanceused: 0 balanceused: 0
}) })
this.props.navigation.navigate('Pickup Name', {from : 'shoppingCart'})
} }
} }
...@@ -297,22 +299,15 @@ class ShoppingCart extends React.Component { ...@@ -297,22 +299,15 @@ class ShoppingCart extends React.Component {
{ {
this.props.type_pickup == true ? ( this.props.type_pickup == true ? (
<TouchableOpacity >
<Card style={{ margin: 5, padding: 10 }}> <Card style={{ margin: 5, padding: 10 }}>
<Text style={{ textAlign: 'center' }}> Ambil pesanan kamu di</Text> <Text style={{ textAlign: 'center' }}> Ambil pesanan kamu di</Text>
<Text style={{ textAlign: 'center', fontSize: 12, top: 5, fontWeight: 'bold' }}>Excelso {this.props.name_outlet}</Text> <Text style={{ textAlign: 'center', fontSize: 12, top: 5, fontWeight: 'bold' }}>Excelso {this.props.name_outlet}</Text>
</Card> </Card>
</TouchableOpacity>
) : ( ) : (
<TouchableOpacity onPress={()=>this.props.navigation.navigate("Delivery Address")}>
<Card style={{ margin: 5, padding: 10 }}> <Card style={{ margin: 5, padding: 10 }}>
<Text style={{ textAlign: 'center' }}> Pesanan kamu dikirim ke</Text> <Text style={{ textAlign: 'center' }}> Pesanan kamu dikirim ke</Text>
<Text style={{ textAlign: 'center' }}>{this.props.address}</Text> <Text style={{ textAlign: 'center' }}>{this.props.address}</Text>
</Card> </Card>
</TouchableOpacity>
) )
} }
</View> </View>
...@@ -346,7 +341,7 @@ class ShoppingCart extends React.Component { ...@@ -346,7 +341,7 @@ class ShoppingCart extends React.Component {
<View style={{ alignItems: 'center' }}> <View style={{ alignItems: 'center' }}>
{ {
this.state.kasproBalance < this.props.order_total ? ( this.state.kasproBalance < this.props.order_total || this.props.order_total == 0 ? (
<Card style={{ margin: 5, padding: 10, backgroundColor: 'gray' }}> <Card style={{ margin: 5, padding: 10, backgroundColor: 'gray' }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}> <View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
<View> <View>
...@@ -384,7 +379,7 @@ class ShoppingCart extends React.Component { ...@@ -384,7 +379,7 @@ class ShoppingCart extends React.Component {
</View> </View>
<View style={{ alignItems: 'center' }}> <View style={{ alignItems: 'center' }}>
{ {
this.state.kasproPoint < this.props.order_total ? ( this.state.kasproPoint < this.props.order_total || this.props.order_total == 0 ? (
<Card style={{ margin: 5, padding: 10, backgroundColor: 'gray' }}> <Card style={{ margin: 5, padding: 10, backgroundColor: 'gray' }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}> <View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
<View> <View>
...@@ -506,9 +501,14 @@ class ShoppingCart extends React.Component { ...@@ -506,9 +501,14 @@ class ShoppingCart extends React.Component {
<View> <View>
<Text style={{ paddingLeft: 20, paddingTop: 10, color: 'gray' }}>Ongkos Kirim</Text> <Text style={{ paddingLeft: 20, paddingTop: 10, color: 'gray' }}>Ongkos Kirim</Text>
</View> </View>
{this.props.order_item.length ? (
<View style={{ paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}> <View style={{ paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}>
<Text style={{ color: 'gray' }}>{this.props.grabamount}</Text> <Text style={{ color: 'gray' }}>{this.props.grabamount}</Text>
</View> </View>
) : (<View style={{ paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}>
<Text style={{ color: 'gray' }}>0</Text>
</View>)}
</View>)} </View>)}
<View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}> <View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}>
...@@ -529,7 +529,12 @@ class ShoppingCart extends React.Component { ...@@ -529,7 +529,12 @@ class ShoppingCart extends React.Component {
</View> </View>
) : ( ) : (
<View style={{ marginTop: 15, paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}> <View style={{ marginTop: 15, paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}>
{this.props.order_item.length ? (
<Text style={{ fontSize: 35, color: '#ccb46c' }}>{this.props.order_total + this.props.grabamount + this.state.diskon}</Text> <Text style={{ fontSize: 35, color: '#ccb46c' }}>{this.props.order_total + this.props.grabamount + this.state.diskon}</Text>
) : (
<Text style={{ fontSize: 35, color: '#ccb46c' }}>{this.props.order_total + this.state.diskon}</Text>
)}
</View> </View>
)} )}
</View> </View>
......
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