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

nambahin pengecekan di delivery dan pickup

parent d5772b63
...@@ -83,6 +83,8 @@ class DeliveryAddrees extends React.Component { ...@@ -83,6 +83,8 @@ class DeliveryAddrees extends React.Component {
}) })
} }
getRate(address_id) { getRate(address_id) {
// console.log('ADdress id : ' + address_id) // console.log('ADdress id : ' + address_id)
...@@ -160,7 +162,9 @@ class DeliveryAddrees extends React.Component { ...@@ -160,7 +162,9 @@ class DeliveryAddrees extends React.Component {
onSave(address, id, name) { onSave(address, id, name) {
if (this.props.value_voucher !== "") {
this.handleVoucherSelect()
} else {
let setDataAddress = { let setDataAddress = {
address: address, address: address,
addressId: id, addressId: id,
...@@ -207,6 +211,7 @@ class DeliveryAddrees extends React.Component { ...@@ -207,6 +211,7 @@ class DeliveryAddrees extends React.Component {
console.log('ini error ' + response.msg) console.log('ini error ' + response.msg)
Alert.alert('', response.msg) Alert.alert('', response.msg)
}) })
}
// let recalculateProps = { // let recalculateProps = {
...@@ -226,7 +231,6 @@ class DeliveryAddrees extends React.Component { ...@@ -226,7 +231,6 @@ class DeliveryAddrees extends React.Component {
// { cancelable: false } // { cancelable: false }
// ) // )
} }
deleteAddress(id) { deleteAddress(id) {
...@@ -242,6 +246,64 @@ class DeliveryAddrees extends React.Component { ...@@ -242,6 +246,64 @@ class DeliveryAddrees extends React.Component {
}) })
} }
handleVoucherSelect() {
//SPINNER ON
this.setState({
spinner: true,
})
//CEK TYPE TRANSAKSINYA DELIVERY OR PICKUP, DICEK UNTUK DI MASUKAN DI PARAMATER PEMANGGILAN API
let type_trans = ""
if (this.props.type_pickup == true) {
type_trans = 'Pickup'
} else {
type_trans = 'Delivery'
}
let params = {
session_id: this.props.session_id,
trans_type: type_trans,
order_item: this.props.order_item,
reward_id: this.props.voucher.id,
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
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);
}
this.setState({
spinner: false,
})
}).catch(error => {
try {
let response = error.response.data
Alert.alert("", response.msg)
this.setState({
spinner: false,
})
// FUNGSI REDUX UNTUK HAPUS VOUCHER
this.props.removeVoucher()
} catch (error) {
Alert.alert("", error.toString())
}
})
}
handleDeleteAddress(id) { handleDeleteAddress(id) {
Alert.alert( Alert.alert(
"", "",
...@@ -394,8 +456,30 @@ const mapStateToProps = (state) => { ...@@ -394,8 +456,30 @@ const mapStateToProps = (state) => {
session_id: state.session_id, session_id: state.session_id,
addressId: state.addressId, addressId: state.addressId,
language: state.language, language: state.language,
outlet_detailadress: state.outlet_detailadress,
home_address: state.home_address,
type_pickup: state.type_pickup,
value_voucher: state.value_voucher,
voucher: state.voucher,
session_id: state.session_id,
outlet_id: state.outlet_id,
name_outlet: state.name_outlet,
value_voucher: state.value_voucher,
voucher: state.voucher,
order_quantity: state.order_quantity,
order_total: state.order_total,
order_item: state.order_item,
quantity: state.quantity,
address: state.address,
addressId: state.addressId,
grabtype: state.grabtype,
grabamount: state.grabamount,
grabpickup: state.grabpickup,
grabdropoff: state.grabdropoff,
grabdestination: state.grabdestination,
BASE_URL: state.BASE_URL BASE_URL: state.BASE_URL
} }
} }
...@@ -445,6 +529,9 @@ const mapDispatchToProps = (dispacth) => { ...@@ -445,6 +529,9 @@ const mapDispatchToProps = (dispacth) => {
type_pickup: type type_pickup: type
} }
}), }),
removeVoucher: () => dispacth({
type: ActionType.REMOVE_VOUCHER
}),
} }
} }
......
...@@ -52,7 +52,7 @@ class Home extends React.Component { ...@@ -52,7 +52,7 @@ class Home extends React.Component {
this.loadAll() this.loadAll()
} }
loadAll(){ loadAll() {
this.CheckInbox() this.CheckInbox()
const screenWidth = Math.round(Dimensions.get('window').width); const screenWidth = Math.round(Dimensions.get('window').width);
...@@ -95,7 +95,7 @@ class Home extends React.Component { ...@@ -95,7 +95,7 @@ class Home extends React.Component {
let params = Object.assign(requestParams, { let params = Object.assign(requestParams, {
session_id: this.props.session_id, session_id: this.props.session_id,
}) })
Axios.post( this.props.BASE_URL + 'crm/v2/inbox/unread_count', params).then(respon => { Axios.post(this.props.BASE_URL + 'crm/v2/inbox/unread_count', params).then(respon => {
let res = respon.data.unread_count let res = respon.data.unread_count
this.setState({ this.setState({
...@@ -188,7 +188,7 @@ class Home extends React.Component { ...@@ -188,7 +188,7 @@ class Home extends React.Component {
let params = Object.assign(requestParams, { let params = Object.assign(requestParams, {
session_id: this.props.session_id, session_id: this.props.session_id,
}) })
this.setState({indicatorProfileCard: true}) this.setState({ indicatorProfileCard: true })
Axios.post(this.props.BASE_URL + 'crm/v2/member/get_profile', params).then(res => { Axios.post(this.props.BASE_URL + 'crm/v2/member/get_profile', params).then(res => {
const dataCard = res.data const dataCard = res.data
...@@ -274,10 +274,18 @@ class Home extends React.Component { ...@@ -274,10 +274,18 @@ class Home extends React.Component {
} }
_pickup() { _pickup() {
let typeProps = {
type_pickup: true,
}
this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Pickup Name', { from: 'home' }); this.props.navigation.navigate('Pickup Name', { from: 'home' });
} }
_delivery() { _delivery() {
let typeProps = {
type_pickup: false,
}
this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Delivery Address', { from: 'home' }); this.props.navigation.navigate('Delivery Address', { from: 'home' });
} }
...@@ -296,9 +304,9 @@ class Home extends React.Component { ...@@ -296,9 +304,9 @@ class Home extends React.Component {
} }
handleClaimCredit() { handleClaimCredit() {
this.setState({spinner: true}) this.setState({ spinner: true })
this.setState({old_balance_claimed: true}) /** set jadi true dulu buat hilangkan bagian claim credit */ this.setState({ old_balance_claimed: true }) /** set jadi true dulu buat hilangkan bagian claim credit */
this.setState({indicatorProfileCard: true}) /** atau sekalian dibuat loading aja bagian profilecardnya */ this.setState({ indicatorProfileCard: true }) /** atau sekalian dibuat loading aja bagian profilecardnya */
let params = Object.assign(requestParams, { let params = Object.assign(requestParams, {
session_id: this.props.session_id, session_id: this.props.session_id,
...@@ -307,7 +315,7 @@ class Home extends React.Component { ...@@ -307,7 +315,7 @@ class Home extends React.Component {
console.log("start processing claim_old_balance") console.log("start processing claim_old_balance")
Axios.post(this.props.BASE_URL + 'crm/v2/card/claim_old_balance', params).then(res => { Axios.post(this.props.BASE_URL + 'crm/v2/card/claim_old_balance', params).then(res => {
console.log("success processing claim_old_balance") console.log("success processing claim_old_balance")
this.setState({spinner: false}) this.setState({ spinner: false })
this._account() this._account()
// Alert.alert(i18n.t('success'), i18n.t('alertclaimcredit')) // Alert.alert(i18n.t('success'), i18n.t('alertclaimcredit'))
}).catch(error => { }).catch(error => {
...@@ -319,7 +327,7 @@ class Home extends React.Component { ...@@ -319,7 +327,7 @@ class Home extends React.Component {
response.msg, response.msg,
[ [
{ {
text: 'OK', onPress: () => this.setState({spinner: false}) text: 'OK', onPress: () => this.setState({ spinner: false })
} }
] ]
); );
...@@ -563,7 +571,7 @@ class Home extends React.Component { ...@@ -563,7 +571,7 @@ class Home extends React.Component {
</View> </View>
</View> </View>
{/* <View style={styles.line2}></View> */} {/* <View style={styles.line2}></View> */}
<View style={{ flexDirection: 'row', flex: 1, display:'none' }}> <View style={{ flexDirection: 'row', flex: 1, display: 'none' }}>
<View style={{ flex: 0.3, justifyContent: 'center' }}> <View style={{ flex: 0.3, justifyContent: 'center' }}>
{/* <Text>{i18n.t('balance')}</Text> */} {/* <Text>{i18n.t('balance')}</Text> */}
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Light' }}>{i18n.t('point')} : </Text> <Text style={{ fontSize: 14, fontFamily: 'Gotham-Light' }}>{i18n.t('point')} : </Text>
...@@ -621,7 +629,7 @@ class Home extends React.Component { ...@@ -621,7 +629,7 @@ class Home extends React.Component {
</View> </View>
</View> </View>
{/* <View style={styles.line2}></View> */} {/* <View style={styles.line2}></View> */}
<View style={{ flexDirection: 'row', flex: 1, display:'none' }}> <View style={{ flexDirection: 'row', flex: 1, display: 'none' }}>
<View style={{ flex: 0.3, justifyContent: 'center' }}> <View style={{ flex: 0.3, justifyContent: 'center' }}>
{/* <Text>{i18n.t('balance')}</Text> */} {/* <Text>{i18n.t('balance')}</Text> */}
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Light' }}>{i18n.t('point')} : </Text> <Text style={{ fontSize: 14, fontFamily: 'Gotham-Light' }}>{i18n.t('point')} : </Text>
...@@ -686,7 +694,7 @@ class Home extends React.Component { ...@@ -686,7 +694,7 @@ class Home extends React.Component {
</View> </View>
</View> </View>
{/* <View style={styles.line2}></View> */} {/* <View style={styles.line2}></View> */}
<View style={{ flexDirection: 'row', flex: 1, display:'none' }}> <View style={{ flexDirection: 'row', flex: 1, display: 'none' }}>
<View style={{ flex: 0.3, justifyContent: 'center' }}> <View style={{ flex: 0.3, justifyContent: 'center' }}>
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Light' }}>{i18n.t('point')} : </Text> <Text style={{ fontSize: 14, fontFamily: 'Gotham-Light' }}>{i18n.t('point')} : </Text>
</View> </View>
...@@ -904,7 +912,14 @@ const mapDispatchToProps = (dispacth) => { ...@@ -904,7 +912,14 @@ const mapDispatchToProps = (dispacth) => {
session_id: configProps.session_id session_id: configProps.session_id
} }
}), }),
setTypePickup: (typeProps) => dispacth({
type: ActionType.SET_TYPE,
data: {
type_pickup: typeProps.type_pickup
}
}),
} }
} }
......
...@@ -273,7 +273,6 @@ class MenuSelection extends React.Component { ...@@ -273,7 +273,6 @@ class MenuSelection extends React.Component {
Alert.alert("", error.toString()) Alert.alert("", error.toString())
} }
}) })
} }
renderTabBar = ({ item }) => { renderTabBar = ({ item }) => {
......
...@@ -39,6 +39,64 @@ class PickupName extends React.Component { ...@@ -39,6 +39,64 @@ class PickupName extends React.Component {
} }
handleVoucherSelect() {
//SPINNER ON
this.setState({
spinner: true,
})
//CEK TYPE TRANSAKSINYA DELIVERY OR PICKUP, DICEK UNTUK DI MASUKAN DI PARAMATER PEMANGGILAN API
let type_trans = ""
if (this.props.type_pickup == true) {
type_trans = 'Pickup'
} else {
type_trans = 'Delivery'
}
let params = {
session_id: this.props.session_id,
trans_type: type_trans,
order_item: this.props.order_item,
reward_id: this.props.voucher.id,
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
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);
}
this.setState({
spinner: false,
})
}).catch(error => {
try {
let response = error.response.data
Alert.alert("", response.msg)
this.setState({
spinner: false,
})
// FUNGSI REDUX UNTUK HAPUS VOUCHER
this.props.removeVoucher()
} catch (error) {
Alert.alert("", error.toString())
}
})
}
_getPermissions = async () => { _getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION); let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') { if (status !== 'granted') {
...@@ -70,6 +128,10 @@ class PickupName extends React.Component { ...@@ -70,6 +128,10 @@ class PickupName extends React.Component {
getOutletDetail(id, name, address) { getOutletDetail(id, name, address) {
if (this.props.value_voucher !== "") {
this.handleVoucherSelect()
}else{
let OutletChange = { let OutletChange = {
outlet_id: id, outlet_id: id,
name_outlet: name, name_outlet: name,
...@@ -96,6 +158,8 @@ class PickupName extends React.Component { ...@@ -96,6 +158,8 @@ class PickupName extends React.Component {
} }
} }
}
getOutlet() { getOutlet() {
this.setState({ this.setState({
spinner: true, spinner: true,
...@@ -192,12 +256,14 @@ class PickupName extends React.Component { ...@@ -192,12 +256,14 @@ class PickupName extends React.Component {
} }
select(item) { select(item) {
let OutletChange = { let OutletChange = {
outlet_id: item.id, outlet_id: item.id,
name_outlet: item.name, name_outlet: item.name,
} }
this.props.setChangeOutletProps(OutletChange) this.props.setChangeOutletProps(OutletChange)
this.props.navigation.navigate('Home', { screen: 'MENU' }); this.props.navigation.navigate('Home', { screen: 'MENU' });
} }
...@@ -391,6 +457,9 @@ const mapDispatchToProps = (dispacth) => { ...@@ -391,6 +457,9 @@ const mapDispatchToProps = (dispacth) => {
} }
}), }),
removeVoucher: () => dispacth({
type: ActionType.REMOVE_VOUCHER
}),
} }
} }
...@@ -402,7 +471,30 @@ const mapStateToProps = (state) => { ...@@ -402,7 +471,30 @@ const mapStateToProps = (state) => {
name_outlet: state.name_outlet, name_outlet: state.name_outlet,
outlet_detailadress: state.outlet_detailadress, outlet_detailadress: state.outlet_detailadress,
language: state.language, language: state.language,
BASE_URL: state.BASE_URL value_voucher: state.value_voucher,
voucher: state.voucher,
outlet_detailadress: state.outlet_detailadress,
home_address: state.home_address,
type_pickup: state.type_pickup,
value_voucher: state.value_voucher,
voucher: state.voucher,
session_id: state.session_id,
outlet_id: state.outlet_id,
name_outlet: state.name_outlet,
value_voucher: state.value_voucher,
voucher: state.voucher,
order_quantity: state.order_quantity,
order_total: state.order_total,
order_item: state.order_item,
quantity: state.quantity,
address: state.address,
addressId: state.addressId,
grabtype: state.grabtype,
grabamount: state.grabamount,
grabpickup: state.grabpickup,
grabdropoff: state.grabdropoff,
grabdestination: state.grabdestination,
BASE_URL: state.BASE_URL,
} }
} }
......
...@@ -9,6 +9,7 @@ import requestParams from '../helper/requestParams'; ...@@ -9,6 +9,7 @@ import requestParams from '../helper/requestParams';
import ActionType from '../redux/globalActionType'; import ActionType from '../redux/globalActionType';
import MyStatusBar from './MyStatusBar'; import MyStatusBar from './MyStatusBar';
import i18n from 'i18n-js'; import i18n from 'i18n-js';
import Spinner from 'react-native-loading-spinner-overlay';
class RewardDetail extends React.Component { class RewardDetail extends React.Component {
constructor(props) { constructor(props) {
...@@ -25,6 +26,7 @@ class RewardDetail extends React.Component { ...@@ -25,6 +26,7 @@ class RewardDetail extends React.Component {
value: '', value: '',
cur_time: '', cur_time: '',
exp_time: '', exp_time: '',
spinner: false
} }
} }
...@@ -33,11 +35,11 @@ class RewardDetail extends React.Component { ...@@ -33,11 +35,11 @@ class RewardDetail extends React.Component {
} }
detailReward() { detailReward() {
let params = Object.assign(requestParams,{ let params = Object.assign(requestParams, {
session_id: this.props.session_id, session_id: this.props.session_id,
reward_id: this.props.route.params.rewardId reward_id: this.props.route.params.rewardId
}) })
Axios.post(this.props.BASE_URL+'crm/v2/reward/get_detail', params).then(res => { Axios.post(this.props.BASE_URL + 'crm/v2/reward/get_detail', params).then(res => {
let exp_time = new Date(res.data.reward.expire_time) let exp_time = new Date(res.data.reward.expire_time)
let cur_time = new Date() let cur_time = new Date()
...@@ -66,15 +68,63 @@ class RewardDetail extends React.Component { ...@@ -66,15 +68,63 @@ class RewardDetail extends React.Component {
} }
useVoucher() { handleVoucherSelect() {
let voucherProps = { //SPINNER ON
value_voucher: this.state.value, this.setState({
voucher: this.state.value spinner: true,
})
//CEK TYPE TRANSAKSINYA DELIVERY OR PICKUP, DICEK UNTUK DI MASUKAN DI PARAMATER PEMANGGILAN API
let type_trans = ""
if (this.props.type_pickup == true) {
type_trans = 'Pickup'
} else {
type_trans = 'Delivery'
} }
let params = {
session_id: this.props.session_id,
trans_type: type_trans,
order_item: this.props.order_item,
reward_id: this.props.route.params.rewardId,
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
Axios.post(this.props.BASE_URL + 'crm/v2/reward/get_value', params).then(res => {
let voucherProps = {
value_voucher: res.data.reward,
voucher: res.data.reward
}
this.props.setVoucher(voucherProps); this.props.setVoucher(voucherProps);
this.setState({
spinner: false,
})
this.props.navigation.navigate('Home', { screen: 'MENU' }) this.props.navigation.navigate('Home', { screen: 'MENU' })
}).catch(error => {
try {
let response = error.response.data;
Alert.alert(
'',
response.msg,
[
{ text: "OK", onPress: () => this.setState({spinner: false}) }
],
);
// FUNGSI REDUX UNTUK HAPUS VOUCHER
this.props.removeVoucher()
} catch (error) {
Alert.alert("", error.toString())
}
})
}
useVoucher() {
this.handleVoucherSelect()
} }
useDVoucher() { useDVoucher() {
...@@ -86,6 +136,7 @@ class RewardDetail extends React.Component { ...@@ -86,6 +136,7 @@ class RewardDetail extends React.Component {
console.log(this.state.content) console.log(this.state.content)
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Spinner visible={this.state.spinner} textContent={'Loading...'} textStyle={{ color: "white" }} />
<MyStatusBar /> <MyStatusBar />
<ScrollView> <ScrollView>
<View style={styles.images}> <View style={styles.images}>
...@@ -250,6 +301,9 @@ const mapDispatchToProps = (dispacth) => { ...@@ -250,6 +301,9 @@ const mapDispatchToProps = (dispacth) => {
} }
}), }),
removeVoucher: () => dispacth({
type: ActionType.REMOVE_VOUCHER
}),
} }
} }
...@@ -260,6 +314,27 @@ const mapStateToProps = (state) => { ...@@ -260,6 +314,27 @@ const mapStateToProps = (state) => {
lat: state.lat, lat: state.lat,
long: state.long, long: state.long,
BASE_URL: state.BASE_URL, BASE_URL: state.BASE_URL,
outlet_detailadress: state.outlet_detailadress,
home_address: state.home_address,
type_pickup: state.type_pickup,
value_voucher: state.value_voucher,
voucher: state.voucher,
session_id: state.session_id,
outlet_id: state.outlet_id,
name_outlet: state.name_outlet,
value_voucher: state.value_voucher,
voucher: state.voucher,
order_quantity: state.order_quantity,
order_total: state.order_total,
order_item: state.order_item,
quantity: state.quantity,
address: state.address,
addressId: state.addressId,
grabtype: state.grabtype,
grabamount: state.grabamount,
grabpickup: state.grabpickup,
grabdropoff: state.grabdropoff,
grabdestination: state.grabdestination,
} }
} }
......
...@@ -18,7 +18,9 @@ class RewardSelect extends React.Component { ...@@ -18,7 +18,9 @@ class RewardSelect extends React.Component {
} }
componentDidMount() { componentDidMount() {
// console.log("INI URL NYA :"+this.props.BASE_URL);
console.log(" DATA PROPS : "+this.props.type_pickup);
this.getRewardsList() this.getRewardsList()
this._unsubscribe = this.props.navigation.addListener('focus', () => { this._unsubscribe = this.props.navigation.addListener('focus', () => {
this.getRewardsList() this.getRewardsList()
...@@ -35,13 +37,12 @@ class RewardSelect extends React.Component { ...@@ -35,13 +37,12 @@ class RewardSelect extends React.Component {
// value_voucher: this.state.value, // value_voucher: this.state.value,
// voucher: this.state.code // voucher: this.state.code
// } // }
// this.props.setVoucher(voucherProps); // this.props.setVoucher(voucherProps);
// this.props.navigation.navigate('Home', { screen: 'MENU' }) // this.props.navigation.navigate('Home', { screen: 'MENU' })
// } // }
handleSelect(item) { handleSelect(item) {
let type_trans = "" let type_trans = ""
if (this.props.type_pickup == true) { if (this.props.type_pickup == true) {
type_trans = 'Pickup' type_trans = 'Pickup'
...@@ -56,7 +57,7 @@ class RewardSelect extends React.Component { ...@@ -56,7 +57,7 @@ class RewardSelect extends React.Component {
reward_id: item.id, reward_id: item.id,
delivery_charge: this.props.grabamount, delivery_charge: this.props.grabamount,
} }
console.log(params) // console.log(params)
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 => {
// console.log(res.data.reward) // console.log(res.data.reward)
let detail = res.data.reward let detail = res.data.reward
......
...@@ -88,15 +88,12 @@ class ShoppingCart extends React.Component { ...@@ -88,15 +88,12 @@ class ShoppingCart extends React.Component {
} }
checkChangeTrans(val) { checkChangeTrans(val) {
if (val == 'delivery') { if (val == 'delivery') {
// let typeProps = { // let typeProps = {
// type_pickup: false, // type_pickup: false,
// } // }
// this.props.setTypePickup(typeProps); // this.props.setTypePickup(typeProps);
if (this.props.value_voucher !== "") {
this.handleVoucherSelect()
}
this.setState({ this.setState({
checkedBalance: false, checkedBalance: false,
checkedPoint: false, checkedPoint: false,
...@@ -105,15 +102,20 @@ class ShoppingCart extends React.Component { ...@@ -105,15 +102,20 @@ class ShoppingCart extends React.Component {
balanceused: 0 balanceused: 0
}) })
let typeProps = {
type_pickup: false,
}
this.props.setTypePickup(typeProps);
this.props.navigation.navigate("Delivery Address", { from: 'shoppingCart' }) this.props.navigation.navigate("Delivery Address", { from: 'shoppingCart' })
} else { } else {
// let typeProps = {
// type_pickup: true, let typeProps = {
// } type_pickup: true,
// this.props.setTypePickup(typeProps);
if (this.props.value_voucher !== "") {
this.handleVoucherSelect()
} }
this.props.setTypePickup(typeProps);
this.setState({ this.setState({
checkedBalance: false, checkedBalance: false,
checkedPoint: false, checkedPoint: false,
...@@ -122,6 +124,7 @@ class ShoppingCart extends React.Component { ...@@ -122,6 +124,7 @@ class ShoppingCart extends React.Component {
balanceused: 0 balanceused: 0
}) })
this.props.navigation.navigate('Pickup Name', { from: 'shoppingCart' }) this.props.navigation.navigate('Pickup Name', { from: 'shoppingCart' })
} }
} }
...@@ -158,13 +161,18 @@ class ShoppingCart extends React.Component { ...@@ -158,13 +161,18 @@ class ShoppingCart extends React.Component {
state_add_remove_voucher: false state_add_remove_voucher: false
}) })
this.props.removeVoucher() this.props.removeVoucher()
this.setState({
spinner: false,
})
} else{ } else{
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({
spinner: false,
})
} }
this.setState({ this.setState({
...@@ -174,10 +182,11 @@ class ShoppingCart extends React.Component { ...@@ -174,10 +182,11 @@ class ShoppingCart extends React.Component {
}).catch(error => { }).catch(error => {
try { try {
let response = error.response.data let response = error.response.data
Alert.alert("", response.msg) console.log("RESPONSE : "+ response)
this.setState({ // Alert.alert("", response.msg)
spinner: false, // this.setState({
}) // spinner: false,
// })
// FUNGSI REDUX UNTUK HAPUS VOUCHER // FUNGSI REDUX UNTUK HAPUS VOUCHER
this.props.removeVoucher() this.props.removeVoucher()
} catch (error) { } catch (error) {
...@@ -187,7 +196,6 @@ class ShoppingCart extends React.Component { ...@@ -187,7 +196,6 @@ class ShoppingCart extends React.Component {
} }
handleRemoveVoucher() { handleRemoveVoucher() {
//panggil spiner //panggil spiner
if (this.props.value_voucher !== "") { if (this.props.value_voucher !== "") {
...@@ -204,9 +212,7 @@ class ShoppingCart extends React.Component { ...@@ -204,9 +212,7 @@ class ShoppingCart extends React.Component {
balanceused: 0, balanceused: 0,
state_add_remove_voucher: true state_add_remove_voucher: true
}) })
// this.props.removeVoucher() // this.props.removeVoucher()
} }
handleAddVoucher() { handleAddVoucher() {
......
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