Commit 8ceb9290 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

benerin delivery address

parent ad94f5ca
......@@ -130,7 +130,7 @@ class DeliveryAddrees extends React.Component {
}).catch(error => {
let response = error.response.data;
Alert.alert('',response.msg);
Alert.alert('', response.msg);
})
}
......@@ -170,32 +170,30 @@ class DeliveryAddrees extends React.Component {
addressId: id,
home_address: name
}
this.props.setAddress(setDataAddress);
let params = {
session_id: this.props.session_id,
address_id: id,
}
Axios.post(this.props.BASE_URL + 'crm/v2/delivery/rate', params).then(res => {
let setGrabProps = {
// grabdestination: this.state.grabdestination,
// grabamount: this.state.grabamount,
grabamount: res.data.data.amount
}
let OutletChange = {
outlet_id: res.data.data.outlet_id,
name_outlet: res.data.data.outlet_name,
}
this.props.setGrab(setGrabProps);
this.props.setChangeOutletProps(OutletChange);
this.props.setTypePickup(false)
if (this.props.route.params.from == 'shoppingCart') {
this.props.navigation.navigate('Shopping Cart', { outlet_change: true, outlet_id: res.data.data.outlet_id })
} else {
......@@ -204,8 +202,8 @@ class DeliveryAddrees extends React.Component {
params: { user: 'janeT' },
});
}
}).catch(error => {
let response = error.response.data;
console.log('ini error ' + response.msg)
......@@ -213,7 +211,7 @@ class DeliveryAddrees extends React.Component {
})
}
// let recalculateProps = {
// order_total: 0,
// order_quantity:0,
......@@ -269,25 +267,14 @@ class DeliveryAddrees extends React.Component {
// MULAI DISINI PEMANGGILAN API DI MULAI, KALAU BERHASIL SET VALUE VOUCHER NYA DAN SPINER DIMATIKAN, KALAU GAGAL CABUT SESSION VOUCHER DAN SPINNER DI MATIKAN
Axios.post(this.props.BASE_URL + 'crm/v2/reward/get_value', params).then(res => {
if (this.state.state_add_remove_voucher == true) {
this.setState({
state_add_remove_voucher: false
})
this.props.removeVoucher()
} else{
let voucherProps = {
value_voucher: res.data.reward,
voucher: res.data.reward
}
this.props.setVoucher(voucherProps);
let voucherProps = {
value_voucher: res.data.reward,
voucher: res.data.reward
}
this.props.setVoucher(voucherProps);
this.setState({
spinner: false,
})
}).catch(error => {
try {
let response = error.response.data
......@@ -298,7 +285,10 @@ class DeliveryAddrees extends React.Component {
// FUNGSI REDUX UNTUK HAPUS VOUCHER
this.props.removeVoucher()
} catch (error) {
Alert.alert("", error.toString())
Alert.alert("Error : ", error.toString())
this.setState({
spinner: false,
})
}
})
}
......@@ -348,10 +338,10 @@ class DeliveryAddrees extends React.Component {
</View>
</TouchableOpacity>
</View>
<View style={{ flex:1}}>
<TouchableOpacity style={{ flex: 1, flexDirection: 'row',justifyContent:"center" }} onPress={() => this.handleDeleteAddress(item.id)}>
<View style={{ alignSelf:"center",marginTop:20}}>
<EvilIcons name="trash" size={40} color="#ccb46c" />
<View style={{ flex: 1 }}>
<TouchableOpacity style={{ flex: 1, flexDirection: 'row', justifyContent: "center" }} onPress={() => this.handleDeleteAddress(item.id)}>
<View style={{ alignSelf: "center", marginTop: 20 }}>
<EvilIcons name="trash" size={40} color="#ccb46c" />
</View>
</TouchableOpacity>
</View>
......@@ -375,7 +365,7 @@ class DeliveryAddrees extends React.Component {
onChangeText={text => this.filterData(text)}
onClear={text => this.filterData('')}
caretHidden={this.state.caretHidden}
onFocus={() => this.setState({caretHidden: false})}
onFocus={() => this.setState({ caretHidden: false })}
value={this.state.search}></TextInput>
</View>
<View style={{ flex: 1, margin: 5 }}>
......@@ -532,6 +522,15 @@ const mapDispatchToProps = (dispacth) => {
removeVoucher: () => dispacth({
type: ActionType.REMOVE_VOUCHER
}),
setVoucher: (voucherProps) => dispacth({
type: ActionType.SET_VOUCHER,
data: {
voucher: voucherProps.voucher,
value_voucher: voucherProps.value_voucher,
}
}),
}
}
......
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