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 {
})
}
getRate(address_id) {
// console.log('ADdress id : ' + address_id)
......@@ -160,55 +162,58 @@ class DeliveryAddrees extends React.Component {
onSave(address, id, name) {
let setDataAddress = {
address: address,
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,
if (this.props.value_voucher !== "") {
this.handleVoucherSelect()
} else {
let setDataAddress = {
address: address,
addressId: id,
home_address: 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 {
this.props.navigation.navigate('Home', {
screen: 'MENU',
params: { user: 'janeT' },
});
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 {
this.props.navigation.navigate('Home', {
screen: 'MENU',
params: { user: 'janeT' },
});
}
}).catch(error => {
let response = error.response.data;
console.log('ini error ' + response.msg)
Alert.alert('', response.msg)
})
}
}).catch(error => {
let response = error.response.data;
console.log('ini error ' + response.msg)
Alert.alert('', response.msg)
})
// let recalculateProps = {
// order_total: 0,
// order_quantity:0,
......@@ -226,7 +231,6 @@ class DeliveryAddrees extends React.Component {
// { cancelable: false }
// )
}
deleteAddress(id) {
......@@ -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) {
Alert.alert(
"",
......@@ -394,8 +456,30 @@ const mapStateToProps = (state) => {
session_id: state.session_id,
addressId: state.addressId,
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
}
}
......@@ -445,6 +529,9 @@ const mapDispatchToProps = (dispacth) => {
type_pickup: type
}
}),
removeVoucher: () => dispacth({
type: ActionType.REMOVE_VOUCHER
}),
}
}
......
......@@ -44,15 +44,15 @@ class Home extends React.Component {
member_since: "",
old_balance: 0,
expired: '',
card_number: ''
card_number: ''
}
}
componentDidMount() {
componentDidMount() {
this.loadAll()
}
loadAll(){
loadAll() {
this.CheckInbox()
const screenWidth = Math.round(Dimensions.get('window').width);
......@@ -95,7 +95,7 @@ class Home extends React.Component {
let params = Object.assign(requestParams, {
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
this.setState({
......@@ -139,7 +139,7 @@ class Home extends React.Component {
this._getCurrentPosisition()
}
}
_getCurrentPosisition = async () => {
_getCurrentPosisition = async () => {
let location = await Location.getCurrentPositionAsync({
accuracy: Location.Accuracy.Highest
})
......@@ -188,7 +188,7 @@ class Home extends React.Component {
let params = Object.assign(requestParams, {
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 => {
const dataCard = res.data
......@@ -269,15 +269,23 @@ class Home extends React.Component {
}
}).catch(error => {
let response = error.response.data
Alert.alert("Error", response.msg)
Alert.alert("Error", response.msg)
})
}
_pickup() {
let typeProps = {
type_pickup: true,
}
this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Pickup Name', { from: 'home' });
}
_delivery() {
let typeProps = {
type_pickup: false,
}
this.props.setTypePickup(typeProps);
this.props.navigation.navigate('Delivery Address', { from: 'home' });
}
......@@ -296,32 +304,32 @@ class Home extends React.Component {
}
handleClaimCredit() {
this.setState({spinner: true})
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({ spinner: true })
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 */
let params = Object.assign(requestParams, {
session_id: this.props.session_id,
})
console.log("start processing claim_old_balance")
Axios.post(this.props.BASE_URL + 'crm/v2/card/claim_old_balance', params).then(res => {
console.log("success processing claim_old_balance")
this.setState({spinner: false})
this.setState({ spinner: false })
this._account()
// Alert.alert(i18n.t('success'), i18n.t('alertclaimcredit'))
}).catch(error => {
console.log("failed processing claim_old_balance")
this._account()
let response = error.response.data
let response = error.response.data
Alert.alert(
"Error",
response.msg,
[
{
text: 'OK', onPress: () => this.setState({spinner: false})
}
]
"Error",
response.msg,
[
{
text: 'OK', onPress: () => this.setState({ spinner: false })
}
]
);
})
}
......@@ -337,7 +345,7 @@ class Home extends React.Component {
style: 'cancel',
},
{
text: i18n.t('alertyes'), onPress: () => {
text: i18n.t('alertyes'), onPress: () => {
this.handleClaimCredit()
}
},
......@@ -356,7 +364,7 @@ class Home extends React.Component {
return (
<View style={styles.container}>
<Spinner visible={this.state.spinner} textContent={'Loading...'} textStyle={{ color: "white" }} />
<Spinner visible={this.state.spinner} textContent={'Loading...'} textStyle={{ color: "white" }} />
{Platform.OS === 'ios' ? (
<CustomIosStatusBar color='#CFB368' />
......@@ -506,7 +514,7 @@ class Home extends React.Component {
</Card>
)
}
{
this.state.indicatorProfileCard == true ? (
<View style={styles.card}>
......@@ -515,7 +523,7 @@ class Home extends React.Component {
</Card>
</View>
) :
//jika member belum punya account kaspro
this.state.account_number == "" ? (
<View style={styles.card}>
......@@ -542,7 +550,7 @@ class Home extends React.Component {
<Text style={{ fontSize: 10, fontFamily: 'Gotham-Light' }}>{i18n.t('cardnumber')}</Text>
</View>
<View style={{ flex: 0.5 }}>
<Text style={{ fontSize: 10, textAlign: 'right', fontFamily: 'Gotham-Light' }}>
<Text style={{ fontSize: 10, textAlign: 'right', fontFamily: 'Gotham-Light' }}>
{i18n.t('expired')} {this.state.expired}
</Text>
</View>
......@@ -563,7 +571,7 @@ class Home extends React.Component {
</View>
</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' }}>
{/* <Text>{i18n.t('balance')}</Text> */}
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Light' }}>{i18n.t('point')} : </Text>
......@@ -572,7 +580,7 @@ class Home extends React.Component {
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Black', color: 'gray' }}>IDR {this.state.point}</Text>
</View>
</View>
</Card>
</Card>
{this.state.old_balance_claimed == false ? (
this.state.old_balance == 0 ? (null) :
(<Card style={{ padding: 10, margin: 10, alignContent: 'center' }}>
......@@ -590,7 +598,7 @@ class Home extends React.Component {
) : (null)}
</View>
) :
/** If gak punya kaspro, dan sudah expired */
this.state.account_number == "" && this.state.is_expired == true ? (
<View style={styles.card}>
......@@ -621,7 +629,7 @@ class Home extends React.Component {
</View>
</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' }}>
{/* <Text>{i18n.t('balance')}</Text> */}
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Light' }}>{i18n.t('point')} : </Text>
......@@ -655,17 +663,17 @@ class Home extends React.Component {
</Card>)
) : (null)}
</View>
) :
/** punya kaspro ( expired atau tidak ) */
(
) :
/** punya kaspro ( expired atau tidak ) */
(
<View style={styles.card}>
<Card style={{ padding: 20, margin: 10, alignContent: 'center' }}>
<View style={{ flexDirection: 'row', flex: 1, paddingBottom: 5 }}>
<View style={{ flex: 0.5 }}>
<Text style={{ fontSize: 10, fontFamily: 'Gotham-Light' }}>{i18n.t('cardnumber')}</Text>
</View>
<View style={{ flex: 0.5 }}>
<View style={{ flex: 0.5 }}>
<Text style={{ fontSize: 10, textAlign: 'right', fontFamily: 'Gotham-Light', color: this.state.expired ? "red" : "" }}>
{i18n.t('expired')} {this.state.expired}
</Text>
......@@ -686,7 +694,7 @@ class Home extends React.Component {
</View>
</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' }}>
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Light' }}>{i18n.t('point')} : </Text>
</View>
......@@ -904,7 +912,14 @@ const mapDispatchToProps = (dispacth) => {
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 {
Alert.alert("", error.toString())
}
})
}
renderTabBar = ({ item }) => {
......
......@@ -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 () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
......@@ -70,30 +128,36 @@ class PickupName extends React.Component {
getOutletDetail(id, name, address) {
let OutletChange = {
outlet_id: id,
name_outlet: name,
outlet_detailadress: address
}
// let recalculateProps = {
// order_total: 0,
// order_quantity:0,
// order_item:[]
// }
// this.props.setRecalculate(recalculateProps)
this.props.setChangeOutletProps(OutletChange);
this.props.setTypePickup(true);
if (this.props.route.params.from == 'shoppingCart') {
this.props.navigation.navigate('Shopping Cart', { outlet_change: true, outlet_id: id })
} else {
this.props.navigation.navigate('Home', {
screen: 'MENU',
params: { user: 'jane' },
})
if (this.props.value_voucher !== "") {
this.handleVoucherSelect()
}else{
let OutletChange = {
outlet_id: id,
name_outlet: name,
outlet_detailadress: address
}
// let recalculateProps = {
// order_total: 0,
// order_quantity:0,
// order_item:[]
// }
// this.props.setRecalculate(recalculateProps)
this.props.setChangeOutletProps(OutletChange);
this.props.setTypePickup(true);
if (this.props.route.params.from == 'shoppingCart') {
this.props.navigation.navigate('Shopping Cart', { outlet_change: true, outlet_id: id })
} else {
this.props.navigation.navigate('Home', {
screen: 'MENU',
params: { user: 'jane' },
})
}
}
}
getOutlet() {
......@@ -192,11 +256,13 @@ class PickupName extends React.Component {
}
select(item) {
let OutletChange = {
outlet_id: item.id,
name_outlet: item.name,
}
this.props.setChangeOutletProps(OutletChange)
let OutletChange = {
outlet_id: item.id,
name_outlet: item.name,
}
this.props.setChangeOutletProps(OutletChange)
this.props.navigation.navigate('Home', { screen: 'MENU' });
}
......@@ -391,6 +457,9 @@ const mapDispatchToProps = (dispacth) => {
}
}),
removeVoucher: () => dispacth({
type: ActionType.REMOVE_VOUCHER
}),
}
}
......@@ -402,7 +471,30 @@ const mapStateToProps = (state) => {
name_outlet: state.name_outlet,
outlet_detailadress: state.outlet_detailadress,
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';
import ActionType from '../redux/globalActionType';
import MyStatusBar from './MyStatusBar';
import i18n from 'i18n-js';
import Spinner from 'react-native-loading-spinner-overlay';
class RewardDetail extends React.Component {
constructor(props) {
......@@ -25,6 +26,7 @@ class RewardDetail extends React.Component {
value: '',
cur_time: '',
exp_time: '',
spinner: false
}
}
......@@ -33,14 +35,14 @@ class RewardDetail extends React.Component {
}
detailReward() {
let params = Object.assign(requestParams,{
let params = Object.assign(requestParams, {
session_id: this.props.session_id,
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 cur_time = new Date()
let expire_date = moment(res.data.reward.expire_time).format('DD MMMM YYYY')
this.setState({
......@@ -66,14 +68,62 @@ class RewardDetail extends React.Component {
}
useVoucher() {
let voucherProps = {
value_voucher: this.state.value,
voucher: this.state.value
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.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.setState({
spinner: false,
})
this.props.navigation.navigate('Home', { screen: 'MENU' })
this.props.setVoucher(voucherProps);
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()
}
......@@ -86,6 +136,7 @@ class RewardDetail extends React.Component {
console.log(this.state.content)
return (
<View style={styles.container}>
<Spinner visible={this.state.spinner} textContent={'Loading...'} textStyle={{ color: "white" }} />
<MyStatusBar />
<ScrollView>
<View style={styles.images}>
......@@ -125,9 +176,9 @@ class RewardDetail extends React.Component {
<View style={styles.content}>
{this.state.cur_time > this.state.exp_time ? (
<View style={{ flex: 1, height: 50, marginRight: 70, marginLeft: 70, justifyContent: 'center' }}>
<View style={{ height: 40, borderRadius: 10, backgroundColor: 'red' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center', margin: 11 }}>{i18n.t('expiredLabel')}</Text>
</View>
<View style={{ height: 40, borderRadius: 10, backgroundColor: 'red' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center', margin: 11 }}>{i18n.t('expiredLabel')}</Text>
</View>
</View>
)
: this.state.used == 0 ? (
......@@ -250,6 +301,9 @@ const mapDispatchToProps = (dispacth) => {
}
}),
removeVoucher: () => dispacth({
type: ActionType.REMOVE_VOUCHER
}),
}
}
......@@ -260,6 +314,27 @@ const mapStateToProps = (state) => {
lat: state.lat,
long: state.long,
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 {
}
componentDidMount() {
// console.log("INI URL NYA :"+this.props.BASE_URL);
console.log(" DATA PROPS : "+this.props.type_pickup);
this.getRewardsList()
this._unsubscribe = this.props.navigation.addListener('focus', () => {
this.getRewardsList()
......@@ -35,13 +37,12 @@ class RewardSelect extends React.Component {
// value_voucher: this.state.value,
// voucher: this.state.code
// }
// this.props.setVoucher(voucherProps);
// this.props.navigation.navigate('Home', { screen: 'MENU' })
// }
handleSelect(item) {
let type_trans = ""
if (this.props.type_pickup == true) {
type_trans = 'Pickup'
......@@ -56,7 +57,7 @@ class RewardSelect extends React.Component {
reward_id: item.id,
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 => {
// console.log(res.data.reward)
let detail = res.data.reward
......
......@@ -88,15 +88,12 @@ class ShoppingCart extends React.Component {
}
checkChangeTrans(val) {
if (val == 'delivery') {
// let typeProps = {
// type_pickup: false,
// }
// this.props.setTypePickup(typeProps);
if (this.props.value_voucher !== "") {
this.handleVoucherSelect()
}
this.setState({
checkedBalance: false,
checkedPoint: false,
......@@ -105,15 +102,20 @@ class ShoppingCart extends React.Component {
balanceused: 0
})
let typeProps = {
type_pickup: false,
}
this.props.setTypePickup(typeProps);
this.props.navigation.navigate("Delivery Address", { from: 'shoppingCart' })
} else {
// let typeProps = {
// type_pickup: true,
// }
// this.props.setTypePickup(typeProps);
if (this.props.value_voucher !== "") {
this.handleVoucherSelect()
let typeProps = {
type_pickup: true,
}
this.props.setTypePickup(typeProps);
this.setState({
checkedBalance: false,
checkedPoint: false,
......@@ -122,6 +124,7 @@ class ShoppingCart extends React.Component {
balanceused: 0
})
this.props.navigation.navigate('Pickup Name', { from: 'shoppingCart' })
}
}
......@@ -158,13 +161,18 @@ class ShoppingCart extends React.Component {
state_add_remove_voucher: false
})
this.props.removeVoucher()
this.setState({
spinner: false,
})
} else{
let voucherProps = {
value_voucher: res.data.reward,
voucher: res.data.reward
}
this.props.setVoucher(voucherProps);
this.setState({
spinner: false,
})
}
this.setState({
......@@ -174,10 +182,11 @@ class ShoppingCart extends React.Component {
}).catch(error => {
try {
let response = error.response.data
Alert.alert("", response.msg)
this.setState({
spinner: false,
})
console.log("RESPONSE : "+ response)
// Alert.alert("", response.msg)
// this.setState({
// spinner: false,
// })
// FUNGSI REDUX UNTUK HAPUS VOUCHER
this.props.removeVoucher()
} catch (error) {
......@@ -187,7 +196,6 @@ class ShoppingCart extends React.Component {
}
handleRemoveVoucher() {
//panggil spiner
if (this.props.value_voucher !== "") {
......@@ -204,9 +212,7 @@ class ShoppingCart extends React.Component {
balanceused: 0,
state_add_remove_voucher: true
})
// this.props.removeVoucher()
}
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