Commit fd26ccc5 authored by Trisno's avatar Trisno

fix bug improvement

parent 57f11248
......@@ -10,14 +10,14 @@ class DeliveryAddrees extends React.Component {
super(props)
this.state = {
data: [],
outlet_id:'',
grabamount:''
outlet_id: '',
grabamount: ''
}
}
componentDidMount() {
this.getAddreess()
console.log("INI ADDRESS ID : "+ this.props.addressId)
console.log("INI ADDRESS ID : " + this.props.addressId)
}
onChangeAddress = data => {
......@@ -72,15 +72,20 @@ class DeliveryAddrees extends React.Component {
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 ")
let setOrdersProps = {
balanceUsed: this.state.balanceused,
pointused: this.state.pointsused,
}
this.props.setOrder(setOrdersProps);
// let setOrdersProps = {
// balanceUsed: this.state.balanceused,
// pointused: this.state.pointsused,
// }
// this.props.setOrder(setOrdersProps);
}).catch(error => {
......@@ -93,40 +98,52 @@ class DeliveryAddrees extends React.Component {
}
onSave(address,id) {
onSave(address, id) {
let setDataAddress = {
address : address,
addressId :id
address: address,
addressId: id
}
this.props.setAddress(setDataAddress);
let recalculateProps = {
order_total: 0,
order_quantity:0,
order_item:[]
this.getRate()
// console.log(this.props)
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") },
],
{ cancelable: false }
)
// let recalculateProps = {
// 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 (
<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, }}>
<Text style={{ fontWeight: 'bold', fontSize: 20 }}>{item.name}</Text>
</View>
......@@ -200,14 +217,22 @@ const mapStateToProps = (state) => {
return {
session_id: state.session_id,
addressId : state.addressId
addressId: state.addressId
}
}
const mapDispatchToProps = (dispacth) => {
return {
setChangeOutletProps: (OutletChange) => dispacth({
type: ActionType.SET_CHANGE_OUTLET,
data: {
outlet_id: OutletChange.outlet_id,
name_outlet: OutletChange.name_outlet,
}
}),
setAddress: (setDataAddress) => dispacth({
type: ActionType.SET_ADDRESS,
data: {
......@@ -230,7 +255,7 @@ const mapDispatchToProps = (dispacth) => {
type: ActionType.SET_RECALCULATE,
data: {
order_total : recalculateProps.order_total,
order_total: recalculateProps.order_total,
order_quantity: recalculateProps.order_quantity,
order_item: recalculateProps.order_item
......@@ -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 {
type_pickup: true,
}
this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Pickup Name');
this.props.navigation.navigate('Pickup Name', {from : 'home'});
}
_order(){
......@@ -145,7 +145,7 @@ class Home extends React.Component {
type_pickup: false,
}
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 {
type_pickup: true,
}
let recalculateProps = {
order_total: 0,
order_quantity:0,
order_item:[]
}
this.props.setRecalculate(recalculateProps)
// let recalculateProps = {
// order_total: 0,
// order_quantity:0,
// order_item:[]
// }
// this.props.setRecalculate(recalculateProps)
this.props.setChangeOutletProps(OutletChange);
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() {
......
......@@ -31,9 +31,9 @@ class ShoppingCart extends React.Component {
grabpickup: '',
grabdropoff: '',
grabdestination: '',
my_lat:0,
my_long:0,
indicator:true,
my_lat: 0,
my_long: 0,
indicator: true,
// dummyBalance : 155000,
// dummyPoint : 20000
......@@ -60,6 +60,7 @@ class ShoppingCart extends React.Component {
pointsused: 0,
balanceused: 0
})
this.props.navigation.navigate("Delivery Address", {from : 'shoppingCart'})
} else {
let typeProps = {
type_pickup: true,
......@@ -72,6 +73,7 @@ class ShoppingCart extends React.Component {
pointsused: 0,
balanceused: 0
})
this.props.navigation.navigate('Pickup Name', {from : 'shoppingCart'})
}
}
......@@ -297,22 +299,15 @@ class ShoppingCart extends React.Component {
{
this.props.type_pickup == true ? (
<TouchableOpacity >
<Card style={{ margin: 5, padding: 10 }}>
<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>
</Card>
</TouchableOpacity>
) : (
<TouchableOpacity onPress={()=>this.props.navigation.navigate("Delivery Address")}>
<Card style={{ margin: 5, padding: 10 }}>
<Text style={{ textAlign: 'center' }}> Pesanan kamu dikirim ke</Text>
<Text style={{ textAlign: 'center' }}>{this.props.address}</Text>
</Card>
</TouchableOpacity>
)
}
</View>
......@@ -346,7 +341,7 @@ class ShoppingCart extends React.Component {
<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' }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
<View>
......@@ -384,7 +379,7 @@ class ShoppingCart extends React.Component {
</View>
<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' }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
<View>
......@@ -506,9 +501,14 @@ class ShoppingCart extends React.Component {
<View>
<Text style={{ paddingLeft: 20, paddingTop: 10, color: 'gray' }}>Ongkos Kirim</Text>
</View>
{this.props.order_item.length ? (
<View style={{ paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}>
<Text style={{ color: 'gray' }}>{this.props.grabamount}</Text>
</View>
) : (<View style={{ paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}>
<Text style={{ color: 'gray' }}>0</Text>
</View>)}
</View>)}
<View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}>
......@@ -529,7 +529,12 @@ class ShoppingCart extends React.Component {
</View>
) : (
<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.state.diskon}</Text>
)}
</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