Commit 347ff4c8 authored by William Goszal's avatar William Goszal 🚴

halaman account, claim balance nya juga dikasih loading

parent b310545b
...@@ -14,12 +14,14 @@ import { connect } from 'react-redux'; ...@@ -14,12 +14,14 @@ import { connect } from 'react-redux';
import requestParams from '../helper/requestParams'; import requestParams from '../helper/requestParams';
import ActionType from '../redux/globalActionType'; import ActionType from '../redux/globalActionType';
import CustomIosStatusBar from './CustomIosStatusBar'; import CustomIosStatusBar from './CustomIosStatusBar';
import Spinner from 'react-native-loading-spinner-overlay';
class Account extends React.Component { class Account extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
spinner: false,
email: "", email: "",
points: "", points: "",
balance: "", balance: "",
...@@ -119,47 +121,47 @@ class Account extends React.Component { ...@@ -119,47 +121,47 @@ class Account extends React.Component {
} }
} }
onClickClaimCredit() {
try {
Alert.alert(
"",
i18n.t('makeSureClaimCredit'),
[
{
text: i18n.t('alertno'),
onPress: () => console.log('Cancel Claim Credit'),
style: 'cancel',
},
{
text: i18n.t('alertyes'), onPress: () => this.handleClaimCredit()
},
],
{ cancelable: false },
)
} catch (error) {
Alert.alert('Error: ' + error)
}
}
handleClaimCredit() { handleClaimCredit() {
try { this.setState({spinner: true})
let params = Object.assign(requestParams, { this.setState({old_balance_claimed: true}) /** set jadi true dulu buat hilangkan bagian claim credit */
session_id: this.props.session_id, this.setState({indicator: true}) /** atau sekalian dibuat loading aja bagian profilecardnya */
})
Axios.post(this.props.BASE_URL + 'crm/v2/card/claim_old_balance', params).then(res => { let params = Object.assign(requestParams, {
Alert.alert(i18n.t('success'), i18n.t('alertclaimcredit')) session_id: this.props.session_id,
}).catch(error => { })
let response = error.response.data
Alert.alert(error, response.msg) Axios.post(this.props.BASE_URL + 'crm/v2/card/claim_old_balance', params).then(res => {
}) this.setState({spinner: false})
} catch (error) { this._getProfile()
Alert.alert('Error : '+ error) // Alert.alert(i18n.t('success'), i18n.t('alertclaimcredit'))
} }).catch(error => {
this.setState({spinner: false})
} this._getProfile()
let response = error.response.data
Alert.alert(error, response.msg)
})
}
onClickClaimCredit() {
Alert.alert(
"",
i18n.t('makeSureClaimCredit'),
[
{
text: i18n.t('alertno'),
onPress: () => console.log('Cancel Claim Credit'),
style: 'cancel',
},
{
text: i18n.t('alertyes'), onPress: () => {
this.handleClaimCredit()
}
},
],
{ cancelable: false },
)
}
_getProfile() { _getProfile() {
try { try {
...@@ -292,6 +294,7 @@ class Account extends React.Component { ...@@ -292,6 +294,7 @@ class Account extends React.Component {
const navigation = this.props.navigation const navigation = this.props.navigation
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Spinner visible={this.state.spinner} textContent={'Loading...'} textStyle={{ color: "white" }} />
{Platform.OS === 'ios' ? ( {Platform.OS === 'ios' ? (
<CustomIosStatusBar color='#CFB368' /> <CustomIosStatusBar color='#CFB368' />
) : null} ) : null}
......
...@@ -299,6 +299,10 @@ class Home extends React.Component { ...@@ -299,6 +299,10 @@ class Home extends React.Component {
} }
handleClaimCredit() { 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 */
let params = Object.assign(requestParams, { let params = Object.assign(requestParams, {
session_id: this.props.session_id, session_id: this.props.session_id,
}) })
...@@ -306,7 +310,7 @@ class Home extends React.Component { ...@@ -306,7 +310,7 @@ class Home extends React.Component {
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 => {
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 => {
this.setState({spinner: false}) this.setState({spinner: false})
this._account() this._account()
...@@ -326,10 +330,7 @@ class Home extends React.Component { ...@@ -326,10 +330,7 @@ class Home extends React.Component {
style: 'cancel', style: 'cancel',
}, },
{ {
text: i18n.t('alertyes'), onPress: () => { text: i18n.t('alertyes'), onPress: () => {
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.handleClaimCredit() this.handleClaimCredit()
} }
}, },
...@@ -561,7 +562,7 @@ class Home extends React.Component { ...@@ -561,7 +562,7 @@ class Home extends React.Component {
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Black', color: 'gray' }}>IDR {this.state.point}</Text> <Text style={{ fontSize: 14, fontFamily: 'Gotham-Black', color: 'gray' }}>IDR {this.state.point}</Text>
</View> </View>
</View> </View>
</Card> </Card>
{this.state.old_balance_claimed == false ? ( {this.state.old_balance_claimed == false ? (
this.state.old_balance == 0 ? (null) : this.state.old_balance == 0 ? (null) :
(<Card style={{ padding: 10, margin: 10, alignContent: 'center' }}> (<Card style={{ padding: 10, margin: 10, alignContent: 'center' }}>
......
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