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

Menambahkan fungsi use balance

parent 5ee9d456
...@@ -181,12 +181,20 @@ class Account extends React.Component { ...@@ -181,12 +181,20 @@ class Account 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 { }
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') 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() {
...@@ -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 { }
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') 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() {
...@@ -265,13 +270,11 @@ class Home extends React.Component { ...@@ -265,13 +270,11 @@ class Home extends React.Component {
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))
}) })
} }
...@@ -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')}
>
<View style={{
flex: 0.5,
height: 40,
top: 20,
margin: 5,
marginLeft: -10,
paddingVertical: 12,
paddingRight: 10,
paddingLeft: 10,
borderRadius: 10,
backgroundColor: '#CFB368',
}}>
<Text style={{ textAlign: 'center', color: 'white', fontFamily: 'Gotham-Black', fontSize: 14 }}>{i18n.t('topup')}</Text> <Text style={{ textAlign: 'center', color: 'white', fontFamily: 'Gotham-Black', fontSize: 14 }}>{i18n.t('topup')}</Text>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity </View>
onPress={() => this._useBalance()}> <View style={{justifyContent:'center',flex:1}}>
<View style={{ <TouchableOpacity onPress={() => this.handleuseBalance()}>
flex: 0.5, <View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', marginRight: 20, marginLeft: 20, justifyContent: 'center' }}>
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> <Text style={{ textAlign: 'center', color: 'white', fontFamily: 'Gotham-Black', fontSize: 14 }}>{i18n.t('usebalance')}</Text>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<View style={{ height: 60 }}></View> </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