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,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() {
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)
}
}
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'),
[
{
text: i18n.t('alertno'),
onPress: () => console.log('Cancel Claim Credit'),
style: 'cancel',
},
{
text: i18n.t('alertyes'), onPress: () => {
this.handleClaimCredit()
}
},
],
{ cancelable: false },
)
}
_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()
......@@ -326,10 +330,7 @@ class Home extends React.Component {
style: 'cancel',
},
{
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 */
text: i18n.t('alertyes'), onPress: () => {
this.handleClaimCredit()
}
},
......@@ -561,7 +562,7 @@ class Home extends React.Component {
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Black', color: 'gray' }}>IDR {this.state.point}</Text>
</View>
</View>
</Card>
</Card>
{this.state.old_balance_claimed == false ? (
this.state.old_balance == 0 ? (null) :
(<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