Commit b231ac43 authored by Trisno's avatar Trisno

pengecekan untuk pemanggilan API get value hanya untuk reward percentage

parent 9b3d5ea8
...@@ -201,7 +201,9 @@ class DeliveryAddrees extends React.Component { ...@@ -201,7 +201,9 @@ class DeliveryAddrees extends React.Component {
} }
if (this.props.value_voucher !== "") { if (this.props.value_voucher !== "") {
this.handleVoucherSelect() if(this.props.value_voucher.reward.type == 'percentage' ) {
this.handleVoucherSelect()
}
} }
}).catch(error => { }).catch(error => {
......
...@@ -243,15 +243,15 @@ class MenuSelection extends React.Component { ...@@ -243,15 +243,15 @@ class MenuSelection 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 = { let voucherProps = {
value_voucher: res.data.reward, value_voucher: res.data.reward,
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
...@@ -319,7 +319,9 @@ class MenuSelection extends React.Component { ...@@ -319,7 +319,9 @@ class MenuSelection extends React.Component {
let res = this.props.addToChart(order_item) let res = this.props.addToChart(order_item)
if (this.props.value_voucher !== "") { if (this.props.value_voucher !== "") {
this.handleVoucherSelect() if (this.props.value_voucher.reward.type == 'percentage') {
this.handleVoucherSelect()
}
} }
// console.log('After add : ' + JSON.stringify(res)) // console.log('After add : ' + JSON.stringify(res))
...@@ -378,7 +380,9 @@ class MenuSelection extends React.Component { ...@@ -378,7 +380,9 @@ class MenuSelection extends React.Component {
} }
} }
if (this.props.value_voucher !== "") { if (this.props.value_voucher !== "") {
this.handleVoucherSelect() if (this.props.value_voucher.reward.type == 'percentage') {
this.handleVoucherSelect()
}
} }
} }
......
...@@ -123,7 +123,9 @@ class PickupName extends React.Component { ...@@ -123,7 +123,9 @@ class PickupName extends React.Component {
getOutletDetail(id, name, address) { getOutletDetail(id, name, address) {
if (this.props.value_voucher !== "") { if (this.props.value_voucher !== "") {
this.handleVoucherSelect() if (this.props.value_voucher.reward.type == 'percentage') {
this.handleVoucherSelect()
}
} }
let OutletChange = { let OutletChange = {
......
...@@ -120,12 +120,12 @@ class ShoppingCart extends React.Component { ...@@ -120,12 +120,12 @@ class ShoppingCart extends React.Component {
let date_time_now = new Date() let date_time_now = new Date()
let exp_time = new Date(this.props.value_voucher.expire_time) let exp_time = new Date(this.props.value_voucher.expire_time)
console.log(date_time_now) // console.log(date_time_now)
console.log(exp_time) // console.log(exp_time)
// console.log(date_time_now > exp_time) // console.log(date_time_now > exp_time)
// console.log(this.props.value_voucher) // console.log(this.props.value_voucher)
if (date_time_now > exp_time) { if (date_time_now > exp_time) {
console.log('tes kepanggil') // console.log('tes kepanggil')
this.props.removeVoucher() this.props.removeVoucher()
} }
...@@ -262,6 +262,7 @@ class ShoppingCart extends React.Component { ...@@ -262,6 +262,7 @@ class ShoppingCart extends React.Component {
} }
handleRemoveVoucher() { handleRemoveVoucher() {
// console.log(this.state.state_add_remove_voucher)
//panggil spiner //panggil spiner
if (this.props.value_voucher !== "") { if (this.props.value_voucher !== "") {
this.handleVoucherSelect() this.handleVoucherSelect()
...@@ -269,6 +270,7 @@ class ShoppingCart extends React.Component { ...@@ -269,6 +270,7 @@ class ShoppingCart extends React.Component {
state_add_remove_voucher: true state_add_remove_voucher: true
}) })
} }
this.setState({ this.setState({
checkedBalance: false, checkedBalance: false,
checkedPoint: false, checkedPoint: false,
...@@ -282,7 +284,9 @@ class ShoppingCart extends React.Component { ...@@ -282,7 +284,9 @@ class ShoppingCart extends React.Component {
handleAddVoucher() { handleAddVoucher() {
if (this.props.value_voucher !== "") { if (this.props.value_voucher !== "") {
this.handleVoucherSelect() if (this.props.value_voucher.reward.type == 'percentage') {
this.handleVoucherSelect()
}
} }
this.setState({ this.setState({
...@@ -330,7 +334,9 @@ class ShoppingCart extends React.Component { ...@@ -330,7 +334,9 @@ class ShoppingCart extends React.Component {
this.props.reduceQuantityItem(order_item) this.props.reduceQuantityItem(order_item)
if (this.props.value_voucher !== "") { if (this.props.value_voucher !== "") {
this.handleVoucherSelect() if (this.props.value_voucher.reward.type == 'percentage') {
this.handleVoucherSelect()
}
} }
if (is_xist.quantity == 0) { if (is_xist.quantity == 0) {
...@@ -356,7 +362,9 @@ class ShoppingCart extends React.Component { ...@@ -356,7 +362,9 @@ class ShoppingCart extends React.Component {
} else { } else {
this.props.reduceQuantityItem(order_item) this.props.reduceQuantityItem(order_item)
if (this.props.value_voucher !== "") { if (this.props.value_voucher !== "") {
this.handleVoucherSelect() if (this.props.value_voucher.reward.type == 'percentage') {
this.handleVoucherSelect()
}
} }
} }
} }
...@@ -394,7 +402,9 @@ class ShoppingCart extends React.Component { ...@@ -394,7 +402,9 @@ class ShoppingCart extends React.Component {
} }
if (this.props.value_voucher !== "") { if (this.props.value_voucher !== "") {
this.handleVoucherSelect() if (this.props.value_voucher.reward.type == 'percentage') {
this.handleVoucherSelect()
}
} }
} }
...@@ -641,7 +651,9 @@ class ShoppingCart extends React.Component { ...@@ -641,7 +651,9 @@ class ShoppingCart extends React.Component {
addItem() { addItem() {
if (this.props.value_voucher !== "") { if (this.props.value_voucher !== "") {
this.handleVoucherSelect() if (this.props.value_voucher.reward.type == 'percentage') {
this.handleVoucherSelect()
}
} }
this.props.navigation.goBack() this.props.navigation.goBack()
...@@ -1014,7 +1026,8 @@ class ShoppingCart extends React.Component { ...@@ -1014,7 +1026,8 @@ class ShoppingCart extends React.Component {
) : ( ) : (
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}> <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
<View style={{ paddingLeft: 20, paddingTop: 5, }}> <View style={{ paddingLeft: 20, paddingTop: 5, }}>
<Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>{i18n.t('discount')}</Text> {/* <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>{i18n.t('discount')}</Text> */}
<Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>{this.props.voucher.reward.title}</Text>
</View> </View>
<View style={{ paddingRight: 20, paddingTop: 5, alignItems: 'flex-end' }}> <View style={{ paddingRight: 20, paddingTop: 5, alignItems: 'flex-end' }}>
<NumberFormat decimalScale={0} value={this.props.voucher.reward.value} renderText={value => <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>- Rp. {value}</Text>} displayType={'text'} thousandSeparator={true} prefix={''} /> <NumberFormat decimalScale={0} value={this.props.voucher.reward.value} renderText={value => <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>- Rp. {value}</Text>} displayType={'text'} thousandSeparator={true} prefix={''} />
......
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