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

Menambahkan fungsi use balance

parent 5ee9d456
...@@ -180,14 +180,22 @@ class Account extends React.Component { ...@@ -180,14 +180,22 @@ class Account extends React.Component {
this.props.navigation.navigate('Transfer Balance'); this.props.navigation.navigate('Transfer Balance');
} }
} }
_useBalance() { handleuseBalance() {
if (this.props.in_payment) { let params = {
this.props.navigation.navigate('Redeem Code') session_id: this.props.session_id
} else {
this.props.navigation.navigate('UseBalance')
} }
} Axios.post(this.props.BASE_URL + 'crm/v2/point/check', params).then(res => {
if (res.data.in_process_redeem == false) {
this.props.navigation.navigate('UseBalance')
} else {
this.props.navigation.navigate('Redeem Code')
}
}).catch(error => {
let response = error.response.data
Alert.alert(error, response.msg)
})
}
render() { render() {
const navigation = this.props.navigation const navigation = this.props.navigation
...@@ -325,7 +333,7 @@ class Account extends React.Component { ...@@ -325,7 +333,7 @@ class Account extends React.Component {
</Card> </Card>
</TouchableOpacity> </TouchableOpacity>
<View style={{ width: 5 }}></View> <View style={{ width: 5 }}></View>
<TouchableOpacity style={{ marginBottom: 5, margin: 3 }} onPress={() => this._useBalance()}> <TouchableOpacity style={{ marginBottom: 5, margin: 3 }} onPress={() => this.handleuseBalance()}>
<Card style={{ height: 120, width: 155 }}> <Card style={{ height: 120, width: 155 }}>
<View style={{ height: 50, alignItems: 'center', padding: 10, flex: 1 }}> <View style={{ height: 50, alignItems: 'center', padding: 10, flex: 1 }}>
<Image <Image
......
...@@ -44,8 +44,8 @@ class Home extends React.Component { ...@@ -44,8 +44,8 @@ class Home extends React.Component {
} }
componentDidMount() { componentDidMount() {
this.CheckInbox() this.CheckInbox()
console.log("INI BASE_URL : " + this.props.BASE_URL)
const screenWidth = Math.round(Dimensions.get('window').width); const screenWidth = Math.round(Dimensions.get('window').width);
this.setState({ this.setState({
slider_height: screenWidth slider_height: screenWidth
...@@ -190,8 +190,6 @@ class Home extends React.Component { ...@@ -190,8 +190,6 @@ class Home extends React.Component {
old_balance_claimed: old_balance_claimed, old_balance_claimed: old_balance_claimed,
member_since: member_since member_since: member_since
}) })
console.log("INI HASIL RESPON NYA :" + JSON.stringify(res))
}).catch(error => { }).catch(error => {
let response = error.response.data let response = error.response.data
// Alert.alert('',response.msg); // Alert.alert('',response.msg);
...@@ -229,13 +227,20 @@ class Home extends React.Component { ...@@ -229,13 +227,20 @@ class Home extends React.Component {
}) })
} }
_useBalance() { handleuseBalance() {
if (this.props.in_payment) { let params = {
this.props.navigation.navigate('Redeem Code') session_id: this.props.session_id
} else {
this.props.navigation.navigate('UseBalance')
} }
Axios.post(this.props.BASE_URL + 'crm/v2/point/check', params).then(res => {
if (res.data.in_process_redeem == false) {
this.props.navigation.navigate('UseBalance')
} else {
this.props.navigation.navigate('Redeem Code')
}
}).catch(error => {
let response = error.response.data
Alert.alert(error, response.msg)
})
} }
_pickup() { _pickup() {
...@@ -259,19 +264,17 @@ class Home extends React.Component { ...@@ -259,19 +264,17 @@ class Home extends React.Component {
Toast.show('Belum dapat outlet terdekat') Toast.show('Belum dapat outlet terdekat')
} }
} }
handleClaimCredit() { handleClaimCredit() {
let params = { let params = {
session_id: this.props.session_id session_id: this.props.session_id
} }
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 => {
Alert.alert(i18n.t('success'), i18n.t('alertclaimcredit')) Alert.alert(i18n.t('success'), i18n.t('alertclaimcredit'))
}).catch(error => { }).catch(error => {
let response = error.response.data let response = error.response.data
Alert.alert(error,response.msg) Alert.alert(error, response.msg)
console.log("INI RESPON CLAMI"+JSON.stringify(error))
}) })
} }
...@@ -428,7 +431,7 @@ class Home extends React.Component { ...@@ -428,7 +431,7 @@ class Home extends React.Component {
<ActivityIndicator style={{ justifyContent: "center" }} size="large" color="#c9af6d" /> <ActivityIndicator style={{ justifyContent: "center" }} size="large" color="#c9af6d" />
</Card> </Card>
</View> </View>
) : ) :
this.state.account_number == "" ? ( this.state.account_number == "" ? (
<View style={styles.card}> <View style={styles.card}>
<Card style={{ padding: 10, margin: 10, alignContent: 'center', backgroundColor: '#838383' }}> <Card style={{ padding: 10, margin: 10, alignContent: 'center', backgroundColor: '#838383' }}>
...@@ -602,45 +605,23 @@ class Home extends React.Component { ...@@ -602,45 +605,23 @@ class Home extends React.Component {
</View> </View>
) )
} }
<View style={{ flexDirection: 'row', flex: 1 }}> <View style={{ flexDirection: 'row', flex: 1,height:40,marginTop:40}}>
<TouchableOpacity <View style={{justifyContent:'center',flex:1}}>
// style={styles.submitUpgradePemium} <TouchableOpacity onPress={() => this.props.navigation.navigate('TopUpInfo')}>
activeOpacity={.5} <View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', marginRight: 20, marginLeft: 20, justifyContent: 'center' }}>
onPress={() => this.props.navigation.navigate('TopUpInfo')} <Text style={{ textAlign: 'center', color: 'white', fontFamily: 'Gotham-Black', fontSize: 14 }}>{i18n.t('topup')}</Text>
> </View>
<View style={{ </TouchableOpacity>
flex: 0.5, </View>
height: 40, <View style={{justifyContent:'center',flex:1}}>
top: 20, <TouchableOpacity onPress={() => this.handleuseBalance()}>
margin: 5, <View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', marginRight: 20, marginLeft: 20, justifyContent: 'center' }}>
marginLeft: -10, <Text style={{ textAlign: 'center', color: 'white', fontFamily: 'Gotham-Black', fontSize: 14 }}>{i18n.t('usebalance')}</Text>
paddingVertical: 12, </View>
paddingRight: 10, </TouchableOpacity>
paddingLeft: 10, </View>
borderRadius: 10,
backgroundColor: '#CFB368',
}}>
<Text style={{ textAlign: 'center', color: 'white', fontFamily: 'Gotham-Black', fontSize: 14 }}>{i18n.t('topup')}</Text>
</View>
</TouchableOpacity>
<TouchableOpacity
onPress={() => this._useBalance()}>
<View style={{
flex: 0.5,
height: 40,
top: 20,
margin: 5,
marginRight: -10,
paddingVertical: 12,
paddingHorizontal: 24,
borderRadius: 10,
backgroundColor: '#CFB368',
}}>
<Text style={{ textAlign: 'center', color: 'white', fontFamily: 'Gotham-Black', fontSize: 14 }}>{i18n.t('usebalance')}</Text>
</View>
</TouchableOpacity>
</View> </View>
<View style={{ height: 60 }}></View> <View style={{ height: 40 }}></View>
</View> </View>
</View> </View>
</ScrollView> </ScrollView>
......
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