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';
import requestParams from '../helper/requestParams';
import ActionType from '../redux/globalActionType';
import CustomIosStatusBar from './CustomIosStatusBar';
import Spinner from 'react-native-loading-spinner-overlay';
class Account extends React.Component {
constructor(props) {
super(props);
this.state = {
spinner: false,
email: "",
points: "",
balance: "",
......@@ -119,9 +121,28 @@ class Account extends React.Component {
}
}
onClickClaimCredit() {
try {
handleClaimCredit() {
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(
"",
i18n.t('makeSureClaimCredit'),
......@@ -132,34 +153,15 @@ class Account extends React.Component {
style: 'cancel',
},
{
text: i18n.t('alertyes'), onPress: () => this.handleClaimCredit()
text: i18n.t('alertyes'), onPress: () => {
this.handleClaimCredit()
}
},
],
{ 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() {
try {
......@@ -292,6 +294,7 @@ class Account extends React.Component {
const navigation = this.props.navigation
return (
<View style={styles.container}>
<Spinner visible={this.state.spinner} textContent={'Loading...'} textStyle={{ color: "white" }} />
{Platform.OS === 'ios' ? (
<CustomIosStatusBar color='#CFB368' />
) : null}
......
......@@ -299,6 +299,10 @@ 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 */
let params = Object.assign(requestParams, {
session_id: this.props.session_id,
})
......@@ -306,7 +310,7 @@ class Home extends React.Component {
Axios.post(this.props.BASE_URL + 'crm/v2/card/claim_old_balance', params).then(res => {
this.setState({spinner: false})
this._account()
Alert.alert(i18n.t('success'), i18n.t('alertclaimcredit'))
// Alert.alert(i18n.t('success'), i18n.t('alertclaimcredit'))
}).catch(error => {
this.setState({spinner: false})
this._account()
......@@ -327,9 +331,6 @@ class Home extends React.Component {
},
{
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()
}
},
......
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