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,9 +121,28 @@ class Account extends React.Component { ...@@ -119,9 +121,28 @@ class Account extends React.Component {
} }
} }
onClickClaimCredit() { handleClaimCredit() {
try { this.setState({spinner: true})
this.setState({old_balance_claimed: true}) /** set jadi true dulu buat hilangkan bagian claim credit */
this.setState({indicator: true}) /** atau sekalian dibuat loading aja bagian profilecardnya */
let params = Object.assign(requestParams, {
session_id: this.props.session_id,
})
Axios.post(this.props.BASE_URL + 'crm/v2/card/claim_old_balance', params).then(res => {
this.setState({spinner: false})
this._getProfile()
// 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( Alert.alert(
"", "",
i18n.t('makeSureClaimCredit'), i18n.t('makeSureClaimCredit'),
...@@ -132,34 +153,15 @@ class Account extends React.Component { ...@@ -132,34 +153,15 @@ class Account extends React.Component {
style: 'cancel', style: 'cancel',
}, },
{ {
text: i18n.t('alertyes'), onPress: () => this.handleClaimCredit() text: i18n.t('alertyes'), onPress: () => {
this.handleClaimCredit()
}
}, },
], ],
{ cancelable: false }, { cancelable: false },
) )
} catch (error) {
Alert.alert('Error: ' + error)
}
}
handleClaimCredit() {
try {
let params = Object.assign(requestParams, {
session_id: this.props.session_id,
})
Axios.post(this.props.BASE_URL + 'crm/v2/card/claim_old_balance', params).then(res => {
Alert.alert(i18n.t('success'), i18n.t('alertclaimcredit'))
}).catch(error => {
let response = error.response.data
Alert.alert(error, response.msg)
})
} catch (error) {
Alert.alert('Error : '+ error)
} }
}
_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()
...@@ -327,9 +331,6 @@ class Home extends React.Component { ...@@ -327,9 +331,6 @@ class Home extends React.Component {
}, },
{ {
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()
} }
}, },
......
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