Commit fe285e90 authored by Trisno's avatar Trisno

state component account info

parent f2e78982
...@@ -46,6 +46,9 @@ class Account extends React.Component { ...@@ -46,6 +46,9 @@ class Account extends React.Component {
full_name: '', full_name: '',
indicator: true, indicator: true,
clickSettings: 0, clickSettings: 0,
old_balance_claimed: false,
old_balance: 0,
is_expired: false
} }
} }
...@@ -103,6 +106,18 @@ class Account extends React.Component { ...@@ -103,6 +106,18 @@ class Account extends React.Component {
this.props.navigation.replace('Login'); 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() { _getProfile() {
let params = { let params = {
session_id: this.props.session_id, session_id: this.props.session_id,
...@@ -114,6 +129,7 @@ class Account extends React.Component { ...@@ -114,6 +129,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 => {
const dataCard = res.data const dataCard = res.data
console.log(dataCard)
let email = dataCard.email let email = dataCard.email
let point = dataCard.kaspro_point let point = dataCard.kaspro_point
let balance = dataCard.kaspro_balance let balance = dataCard.kaspro_balance
...@@ -123,6 +139,9 @@ class Account extends React.Component { ...@@ -123,6 +139,9 @@ class Account extends React.Component {
let premium = dataCard.kaspro_is_premium let premium = dataCard.kaspro_is_premium
let kaspro = dataCard.kaspro_account_number let kaspro = dataCard.kaspro_account_number
let full_name = dataCard.name 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 === "") { if (kaspro === "") {
...@@ -152,7 +171,11 @@ class Account extends React.Component { ...@@ -152,7 +171,11 @@ class Account extends React.Component {
expire_date: expire, expire_date: expire,
premium: premium, premium: premium,
full_name: full_name, full_name: full_name,
indicator: false indicator: false,
old_balance_claimed: old_balance_claimed,
old_balance: old_balance,
is_expired: is_expired
}) })
}).catch(error => { }).catch(error => {
...@@ -180,22 +203,22 @@ class Account extends React.Component { ...@@ -180,22 +203,22 @@ class Account extends React.Component {
this.props.navigation.navigate('Transfer Balance'); this.props.navigation.navigate('Transfer Balance');
} }
} }
handleuseBalance() { handleuseBalance() {
let params = { let params = {
session_id: this.props.session_id session_id: this.props.session_id
} }
Axios.post(this.props.BASE_URL + 'crm/v2/point/check', params).then(res => { Axios.post(this.props.BASE_URL + 'crm/v2/point/check', params).then(res => {
if (res.data.in_process_redeem == false) { if (res.data.in_process_redeem == false) {
this.props.navigation.navigate('UseBalance') this.props.navigation.navigate('UseBalance')
} else { } else {
this.props.navigation.navigate('Redeem Code') this.props.navigation.navigate('Redeem Code')
} }
}).catch(error => { }).catch(error => {
let response = error.response.data let response = error.response.data
Alert.alert(error, response.msg) Alert.alert(error, response.msg)
}) })
} }
render() { render() {
const navigation = this.props.navigation const navigation = this.props.navigation
...@@ -265,43 +288,73 @@ class Account extends React.Component { ...@@ -265,43 +288,73 @@ class Account extends React.Component {
<ActivityIndicator style={{ justifyContent: "center" }} size="large" color="#c9af6d" /> <ActivityIndicator style={{ justifyContent: "center" }} size="large" color="#c9af6d" />
</Card> </Card>
) : ( ) : (
<Card style={{ padding: 20, alignContent: 'center' }}> <>
<View style={{ flexDirection: 'row', flex: 1, paddingBottom: 5 }}> <Card style={{ padding: 20, alignContent: 'center' }}>
<View style={{ flex: 0.5 }}> <View style={{ flexDirection: 'row', flex: 1, paddingBottom: 5 }}>
<Text style={{ fontSize: 10, fontFamily: 'Gotham-Light' }}>{i18n.t('cardnumber')}</Text> <View style={{ flex: 0.5 }}>
</View> <Text style={{ fontSize: 10, fontFamily: 'Gotham-Light' }}>{i18n.t('cardnumber')}</Text>
<View style={{ flex: 0.5 }}> </View>
<Text style={{ fontSize: 10, textAlign: 'right', fontFamily: 'Gotham-Light' }}>{i18n.t('expired')} {this.state.expire_date}</Text> <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>
</View> <View style={{ paddingHorizontal: 10 }}>
<View style={{ paddingHorizontal: 10 }}> <Text style={{ textAlign: "center", fontSize: 30, color: '#c9af6d', fontFamily: 'Gotham-Black' }}>
<Text style={{ textAlign: "center", fontSize: 30, color: '#c9af6d', fontFamily: 'Gotham-Black' }}> {this.state.account_number}
{this.state.account_number} </Text>
</Text>
</View>
<View style={styles.line}></View>
<View style={{ flexDirection: 'row', flex: 1 }}>
<View style={{ flex: 0.3, justifyContent: 'center' }}>
{/* <Text>{i18n.t('balance')}</Text> */}
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Light' }}>{i18n.t('balance')}</Text>
</View> </View>
<View style={{ flex: 0.7, alignItems: 'center' }}> <View style={styles.line}></View>
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Black', color: 'gray' }}>IDR {this.state.balance}</Text>
<View style={{ flexDirection: 'row', flex: 1 }}>
<View style={{ flex: 0.3, justifyContent: 'center' }}>
{/* <Text>{i18n.t('balance')}</Text> */}
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Light' }}>{i18n.t('balance')}</Text>
</View>
<View style={{ flex: 0.7, alignItems: 'center' }}>
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Black', color: 'gray' }}>IDR {this.state.balance}</Text>
</View>
</View> </View>
</View>
<View style={styles.line2}></View> <View style={styles.line2}></View>
<View style={{ flexDirection: 'row', flex: 1 }}> <View style={{ flexDirection: 'row', flex: 1 }}>
<View style={{ flex: 0.3, justifyContent: 'center' }}> <View style={{ flex: 0.3, justifyContent: 'center' }}>
{/* <Text>{i18n.t('balance')}</Text> */} {/* <Text>{i18n.t('balance')}</Text> */}
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Light' }}>{i18n.t('point')}</Text> <Text style={{ fontSize: 14, fontFamily: 'Gotham-Light' }}>{i18n.t('point')}</Text>
</View>
<View style={{ flex: 0.7, alignItems: 'center' }}>
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Black', color: 'gray' }}>IDR {this.state.points}</Text>
</View>
</View> </View>
<View style={{ flex: 0.7, alignItems: 'center' }}> {
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Black', color: 'gray' }}>IDR {this.state.points}</Text> this.state.is_expired ? (
</View> <TouchableOpacity onPress={() => this.props.navigation.navigate('Renewal')}>
</View> <View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', marginRight: 20, marginLeft: 20, marginTop:20, justifyContent: 'center' }}>
</Card> <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> </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