Commit c874d5d8 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

benerin reward detail

parent e60f9689
...@@ -88,10 +88,10 @@ class RewardDetail extends React.Component { ...@@ -88,10 +88,10 @@ class RewardDetail extends React.Component {
reward_id: this.props.route.params.rewardId, reward_id: this.props.route.params.rewardId,
delivery_charge: this.props.grabamount, delivery_charge: this.props.grabamount,
} }
// 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 = { let voucherProps = {
value_voucher: res.data.reward, value_voucher: res.data.reward,
voucher: res.data.reward voucher: res.data.reward
...@@ -100,22 +100,30 @@ class RewardDetail extends React.Component { ...@@ -100,22 +100,30 @@ class RewardDetail extends React.Component {
this.setState({ this.setState({
spinner: false, spinner: false,
}) })
this.props.navigation.navigate('Home', { screen: 'MENU' }) this.props.navigation.navigate('Home', { screen: 'MENU' })
}).catch(error => { }).catch(error => {
try { try {
let response = error.response.data; let response = error.response.data;
Alert.alert( if (response.code == "REWARD_CANNOT_BE_USED") {
'', this.setState({
response.msg, spinner: false,
[ })
{ text: "OK", onPress: () => this.setState({spinner: false}) } this.props.navigation.navigate('Home', { screen: 'MENU' })
], } else {
); Alert.alert(
// FUNGSI REDUX UNTUK HAPUS VOUCHER '',
this.props.removeVoucher() response.msg,
[
{ text: "OK", onPress: () => this.setState({ spinner: false }) }
],
);
// FUNGSI REDUX UNTUK HAPUS VOUCHER
this.props.removeVoucher()
}
} catch (error) { } catch (error) {
Alert.alert("", error.toString()) Alert.alert("", error.toString())
} }
...@@ -124,7 +132,7 @@ class RewardDetail extends React.Component { ...@@ -124,7 +132,7 @@ class RewardDetail extends React.Component {
} }
useVoucher() { useVoucher() {
this.handleVoucherSelect() this.handleVoucherSelect()
} }
......
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