Commit 887cbbe4 authored by Trisno's avatar Trisno

update state component

parent a32e5c35
...@@ -50,7 +50,7 @@ class Account extends React.Component { ...@@ -50,7 +50,7 @@ class Account extends React.Component {
old_balance_claimed: false, old_balance_claimed: false,
old_balance: 0, old_balance: 0,
is_expired: false, is_expired: false,
card_number:"", card_number: "",
} }
} }
...@@ -131,7 +131,9 @@ class Account extends React.Component { ...@@ -131,7 +131,9 @@ class Account extends React.Component {
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'))
Toast.show(i18n.t('alertclaimcredit'))
this._getProfile()
}).catch(error => { }).catch(error => {
let response = error.response.data let response = error.response.data
Alert.alert(error, response.msg) Alert.alert(error, response.msg)
...@@ -148,7 +150,7 @@ class Account extends React.Component { ...@@ -148,7 +150,7 @@ class Account extends React.Component {
} }
Axios.post(this.props.BASE_URL + 'crm/v2/member/get_profile', params).then(res => { Axios.post(this.props.BASE_URL + 'crm/v2/member/get_profile', params).then(res => {
console.log("INI DATANYA : " +JSON.stringify(res)) console.log("INI DATANYA : " + JSON.stringify(res))
const dataCard = res.data const dataCard = res.data
console.log(dataCard) console.log(dataCard)
let email = dataCard.email let email = dataCard.email
...@@ -165,6 +167,7 @@ class Account extends React.Component { ...@@ -165,6 +167,7 @@ class Account extends React.Component {
let is_expired = dataCard.is_expired let is_expired = dataCard.is_expired
let card_number = dataCard.card_number let card_number = dataCard.card_number
if (kaspro === "") { if (kaspro === "") {
let cardProps = { let cardProps = {
...@@ -183,10 +186,30 @@ class Account extends React.Component { ...@@ -183,10 +186,30 @@ class Account extends React.Component {
let account_number = dataCard.card_number let account_number = dataCard.card_number
let setCardNumberProps = { let setCardNumberProps = {
card_number : account_number card_number: account_number
} }
this.props.setCardNumber(setCardNumberProps) this.props.setCardNumber(setCardNumberProps)
if (old_balance == 0) {
this.setState({
email: email,
points: point,
img_card: img_card,
member_since: member_since,
balance: balance,
account_number: account_number,
img_card: img_card,
expire_date: expire,
premium: premium,
full_name: full_name,
indicator: false,
old_balance_claimed: true,
old_balance: old_balance,
is_expired: is_expired,
card_number: card_number
})
} else {
this.setState({ this.setState({
email: email, email: email,
points: point, points: point,
...@@ -202,9 +225,10 @@ class Account extends React.Component { ...@@ -202,9 +225,10 @@ class Account extends React.Component {
old_balance_claimed: old_balance_claimed, old_balance_claimed: old_balance_claimed,
old_balance: old_balance, old_balance: old_balance,
is_expired: is_expired, is_expired: is_expired,
card_number:card_number card_number: card_number
}) })
}
}).catch(error => { }).catch(error => {
// const { navigation } = this.props // const { navigation } = this.props
...@@ -361,7 +385,7 @@ class Account extends React.Component { ...@@ -361,7 +385,7 @@ class Account extends React.Component {
{ {
this.state.is_expired ? ( this.state.is_expired ? (
<TouchableOpacity onPress={() => this.props.navigation.navigate('Renewal')}> <TouchableOpacity onPress={() => this.props.navigation.navigate('Renewal')}>
<View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', marginRight: 20, marginLeft: 20, marginTop:20, justifyContent: 'center' }}> <View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', marginRight: 20, marginLeft: 20, marginTop: 20, justifyContent: 'center' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center', margin: 15 }}>RENEWAL</Text> <Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center', margin: 15 }}>RENEWAL</Text>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
...@@ -372,7 +396,7 @@ class Account extends React.Component { ...@@ -372,7 +396,7 @@ class Account extends React.Component {
<Card style={{ padding: 10, margin: 10, alignContent: 'center' }}> <Card style={{ padding: 10, margin: 10, alignContent: 'center' }}>
<View style={{ flex: 1, height: 80, borderRadius: 20, marginRight: 10, marginLeft: 10, justifyContent: 'center' }}> <View style={{ flex: 1, height: 80, borderRadius: 20, marginRight: 10, marginLeft: 10, justifyContent: 'center' }}>
{/* <Text style={{ fontSize: 14, fontFamily: 'Gotham-Light', textAlign: 'center', marginBottom: 10 }}>CREDIT : {this.state.old_balance} </Text> */} {/* <Text style={{ fontSize: 14, fontFamily: 'Gotham-Light', textAlign: 'center', marginBottom: 10 }}>CREDIT : {this.state.old_balance} </Text> */}
<NumberFormat decimalScale={0} value={this.state.old_balance} renderText={value => <Text style={{ fontSize: 14, fontFamily: 'Gotham-Light', textAlign: 'center', marginBottom: 10, color:'#838383' }}>CREDIT : Rp. {value}</Text>} displayType={'text'} thousandSeparator={true} prefix={''} /> <NumberFormat decimalScale={0} value={this.state.old_balance} renderText={value => <Text style={{ fontSize: 14, fontFamily: 'Gotham-Light', textAlign: 'center', marginBottom: 10, color: '#838383' }}>CREDIT : Rp. {value}</Text>} displayType={'text'} thousandSeparator={true} prefix={''} />
<View style={{ justifyContent: 'center' }}> <View style={{ justifyContent: 'center' }}>
<TouchableOpacity onPress={() => this.onClickClaimCredit()}> <TouchableOpacity onPress={() => this.onClickClaimCredit()}>
<View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', marginRight: 20, marginLeft: 20, justifyContent: 'center' }}> <View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', marginRight: 20, marginLeft: 20, justifyContent: '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