Commit fe285e90 authored by Trisno's avatar Trisno

state component account info

parent f2e78982
......@@ -46,6 +46,9 @@ class Account extends React.Component {
full_name: '',
indicator: true,
clickSettings: 0,
old_balance_claimed: false,
old_balance: 0,
is_expired: false
}
}
......@@ -103,6 +106,18 @@ class Account extends React.Component {
this.props.navigation.replace('Login');
}
handleClaimCredit() {
let params = {
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)
})
}
_getProfile() {
let params = {
session_id: this.props.session_id,
......@@ -114,6 +129,7 @@ class Account extends React.Component {
Axios.post(this.props.BASE_URL + 'crm/v2/member/get_profile', params).then(res => {
const dataCard = res.data
console.log(dataCard)
let email = dataCard.email
let point = dataCard.kaspro_point
let balance = dataCard.kaspro_balance
......@@ -123,6 +139,9 @@ class Account extends React.Component {
let premium = dataCard.kaspro_is_premium
let kaspro = dataCard.kaspro_account_number
let full_name = dataCard.name
let old_balance_claimed = dataCard.old_balance_claimed
let old_balance = dataCard.old_balance
let is_expired = dataCard.is_expired
if (kaspro === "") {
......@@ -152,7 +171,11 @@ class Account extends React.Component {
expire_date: expire,
premium: premium,
full_name: full_name,
indicator: false
indicator: false,
old_balance_claimed: old_balance_claimed,
old_balance: old_balance,
is_expired: is_expired
})
}).catch(error => {
......@@ -265,13 +288,19 @@ class Account extends React.Component {
<ActivityIndicator style={{ justifyContent: "center" }} size="large" color="#c9af6d" />
</Card>
) : (
<>
<Card style={{ padding: 20, alignContent: 'center' }}>
<View style={{ flexDirection: 'row', flex: 1, paddingBottom: 5 }}>
<View style={{ flex: 0.5 }}>
<Text style={{ fontSize: 10, fontFamily: 'Gotham-Light' }}>{i18n.t('cardnumber')}</Text>
</View>
<View style={{ flex: 0.5 }}>
{this.state.is_expired ? (
<Text style={{ fontSize: 10, textAlign: 'right', fontFamily: 'Gotham-Light', color: '#d34343' }}>Expired</Text>
) : (
<Text style={{ fontSize: 10, textAlign: 'right', fontFamily: 'Gotham-Light' }}>{i18n.t('expired')} {this.state.expire_date}</Text>
)
}
</View>
</View>
<View style={{ paddingHorizontal: 10 }}>
......@@ -301,7 +330,31 @@ class Account extends React.Component {
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Black', color: 'gray' }}>IDR {this.state.points}</Text>
</View>
</View>
{
this.state.is_expired ? (
<TouchableOpacity onPress={() => this.props.navigation.navigate('Renewal')}>
<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>
</View>
</TouchableOpacity>
) : null
}
</Card>
{this.state.old_balance_claimed == false ? (
<Card style={{ padding: 10, margin: 10, alignContent: '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>
<View style={{ justifyContent: 'center' }}>
<TouchableOpacity onPress={() => this.handleClaimCredit()}>
<View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', marginRight: 20, marginLeft: 20, justifyContent: 'center' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center', margin: 15 }}>CLAIM CREDIT</Text>
</View>
</TouchableOpacity>
</View>
</View>
</Card>) : (null)}
</>
)
}
</View>
......
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