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