Commit c4940e3f authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

nambahin try cath untuk menangkap error di hp pak benny

parent 0c07d48d
...@@ -51,444 +51,504 @@ class Account extends React.Component { ...@@ -51,444 +51,504 @@ 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: "",
} }
} }
componentDidMount() { componentDidMount() {
this._getProfile() try {
this._unsubscribe = this.props.navigation.addListener('focus', () => {
this.setState({
indicator: true
})
this._getProfile() this._getProfile()
}); this._unsubscribe = this.props.navigation.addListener('focus', () => {
this.setState({
indicator: true
})
this._getProfile()
});
} catch (error) {
Alert.alert('Error' + error)
}
} }
componentWillUnmount() { componentWillUnmount() {
this._unsubscribe(); try {
this._unsubscribe();
} catch (error) {
Alert.alert('Error : ' + error)
}
} }
_getPermissions = async () => { _getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION); try {
if (status !== 'granted') { let { status } = await Permissions.askAsync(Permissions.LOCATION);
Alert.alert('Akses tidak dizinkan!') if (status !== 'granted') {
} else if (Platform.OS === 'android' && !Device.isDevice) { Alert.alert('Akses tidak dizinkan!')
} else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert('Silahkan anda coba di real Device')
} else { Alert.alert('Silahkan anda coba di real Device')
this._getCurrentPosisition() } else {
this._getCurrentPosisition()
}
} catch (error) {
Alert.alert('Error : ' + error)
} }
} }
_getCurrentPosisition = async () => { _getCurrentPosisition = async () => {
this.setState({ try {
spinner: true, this.setState({
}) spinner: true,
let location = await Location.getCurrentPositionAsync({ })
accuracy: Location.Accuracy.Highest let location = await Location.getCurrentPositionAsync({
}) accuracy: Location.Accuracy.Highest
})
let latitude = location.coords.latitude;
let longitude = location.coords.longitude; let latitude = location.coords.latitude;
let longitude = location.coords.longitude;
this.setState({
my_lat: latitude, this.setState({
my_long: longitude my_lat: latitude,
}) my_long: longitude
})
this._getProfile()
this._getProfile()
} catch (error) {
Alert.alert('Error: + ', error)
}
} }
logout() { logout() {
let configProps = { try {
session_id: '' let configProps = {
session_id: ''
}
this.props.setConfig(configProps);
this.props.navigation.replace('Login');
} catch (error) {
Alert.alert('ERROR : ' + error)
} }
this.props.setConfig(configProps);
this.props.navigation.replace('Login');
} }
onClickClaimCredit() { onClickClaimCredit() {
Alert.alert( try {
"",
"Are you sure want to claim credit ?", Alert.alert(
[ "",
{ "Are you sure want to claim credit ?",
text: 'No', [
onPress: () => console.log('Cancel Claim Credit'), {
style: 'cancel', text: 'No',
}, onPress: () => console.log('Cancel Claim Credit'),
{ style: 'cancel',
text: 'Yes', onPress: () => this.handleClaimCredit() },
}, {
], text: 'Yes', onPress: () => this.handleClaimCredit()
{ cancelable: false }, },
) ],
{ cancelable: false },
)
} catch (error) {
Alert.alert('Error: ' + error)
}
} }
handleClaimCredit() { handleClaimCredit() {
let params = Object.assign(requestParams,{ try {
session_id: this.props.session_id, 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')) Axios.post(this.props.BASE_URL + 'crm/v2/card/claim_old_balance', params).then(res => {
}).catch(error => { Alert.alert(i18n.t('success'), i18n.t('alertclaimcredit'))
let response = error.response.data }).catch(error => {
Alert.alert(error, response.msg) let response = error.response.data
}) Alert.alert(error, response.msg)
})
} catch (error) {
Alert.alert('Error : '+ error)
}
} }
_getProfile() { _getProfile() {
let params = Object.assign(requestParams,{ try {
session_id: this.props.session_id,
lat: this.state.my_lat,
long: this.state.my_long,
closest_outlet: 1
})
Axios.post(this.props.BASE_URL + 'crm/v2/member/get_profile', params).then(res => {
console.log("INI DATANYA : " +JSON.stringify(res))
const dataCard = res.data
console.log(dataCard)
let email = dataCard.email
let point = dataCard.kaspro_point
let balance = dataCard.kaspro_balance
let img_card = dataCard.card_series_image
let member_since = dataCard.member_since
let expire = dataCard.expire_date
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
let card_number = dataCard.card_number
let account_number = dataCard.account_number
if (kaspro === "") {
let cardProps = {
set_card: false
let params = Object.assign(requestParams, {
session_id: this.props.session_id,
lat: this.state.my_lat,
long: this.state.my_long,
closest_outlet: 1
})
Axios.post(this.props.BASE_URL + 'crm/v2/member/get_profile', params).then(res => {
console.log("INI DATANYA : " + JSON.stringify(res))
const dataCard = res.data
console.log(dataCard)
let email = dataCard.email
let point = dataCard.kaspro_point
let balance = dataCard.kaspro_balance
let img_card = dataCard.card_series_image
let member_since = dataCard.member_since
let expire = dataCard.expire_date
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
let card_number = dataCard.card_number
let account_number = dataCard.account_number
if (kaspro === "") {
let cardProps = {
set_card: false
}
this.props.setCardactive(cardProps)
} else {
let cardProps = {
set_card: true
}
this.props.setCardactive(cardProps)
} }
this.props.setCardactive(cardProps) this.setState({
} else { email: email,
let cardProps = { points: point,
set_card: true 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: old_balance_claimed,
old_balance: old_balance,
is_expired: is_expired,
card_number: card_number
})
let setCardNumberProps = {
card_number: this.state.card_number
} }
this.props.setCardactive(cardProps) this.props.setCardNumber(setCardNumberProps)
}
}).catch(error => {
this.setState({ // const { navigation } = this.props
email: email, // let response = error.response.data
points: point, // session(response, navigation)
img_card: img_card, let response = error.response.data
member_since: member_since, // Alert.alert('',response.msg);
balance: balance, Toast.show(response.msg)
account_number: account_number,
img_card: img_card,
expire_date: expire,
premium: premium,
full_name: full_name,
indicator: false,
old_balance_claimed: old_balance_claimed,
old_balance: old_balance,
is_expired: is_expired,
card_number: card_number
}) })
let setCardNumberProps = { } catch (error) {
card_number: this.state.card_number Alert.alert('Error :' + error)
} }
this.props.setCardNumber(setCardNumberProps)
}).catch(error => {
// const { navigation } = this.props
// let response = error.response.data
// session(response, navigation)
let response = error.response.data
// Alert.alert('',response.msg);
Toast.show(response.msg)
})
} }
TransferBalance() { TransferBalance() {
if (this.state.premium === false) { try {
Alert.alert( if (this.state.premium === false) {
'Akun Belum Premium', Alert.alert(
'Apakah anda ingin Upgrade Premium ?', 'Akun Belum Premium',
'Apakah anda ingin Upgrade Premium ?',
[{ text: 'Cancel' },
{ text: 'OK', onPress: () => this.props.navigation.navigate('Upgrade Premium') } [{ text: 'Cancel' },
] { text: 'OK', onPress: () => this.props.navigation.navigate('Upgrade Premium') }
) ]
} else { )
this.props.navigation.navigate('Transfer Balance'); } else {
this.props.navigation.navigate('Transfer Balance');
}
} catch (error) {
Alert.alert('Error : ' + error)
} }
} }
handleuseBalance() { handleuseBalance() {
let params = Object.assign(requestParams,{ try {
session_id: this.props.session_id, let params = Object.assign(requestParams, {
}) session_id: this.props.session_id,
Axios.post(this.props.BASE_URL + 'crm/v2/point/check', params).then(res => { })
if (res.data.in_process_redeem == false) { Axios.post(this.props.BASE_URL + 'crm/v2/point/check', params).then(res => {
this.props.navigation.navigate('UseBalance') if (res.data.in_process_redeem == false) {
} else { this.props.navigation.navigate('UseBalance')
this.props.navigation.navigate('Redeem Code') } else {
} this.props.navigation.navigate('Redeem Code')
}).catch(error => { }
let response = error.response.data }).catch(error => {
Alert.alert(error, response.msg) let response = error.response.data
}) Alert.alert(error, response.msg)
})
} catch (error) {
Alert.alert('Error:' + error)
}
} }
render() { render() {
const navigation = this.props.navigation try {
return ( const navigation = this.props.navigation
<View style={styles.container}> return (
<ScrollView style={{paddingTop: StatusBar.currentHeight}}> <View style={styles.container}>
<ScrollView style={{ paddingTop: StatusBar.currentHeight }}>
<View style={{ flex: 1, height: 90 }}>
<View style={{ alignSelf: 'center' }}> <View style={{ flex: 1, height: 90 }}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Profile')}> <View style={{ alignSelf: 'center' }}>
<Image <TouchableOpacity onPress={() => this.props.navigation.navigate('Profile')}>
style={{ height: 70, width: 70, justifyContent: 'center', top: 20 }} <Image
source={require('../assets/images/people-actv.png')} style={{ height: 70, width: 70, justifyContent: 'center', top: 20 }}
/> source={require('../assets/images/people-actv.png')}
</TouchableOpacity> />
</View> </TouchableOpacity>
<View style={{ height: 90, justifyContent: 'center' }}> </View>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Profile')}> <View style={{ height: 90, justifyContent: 'center' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center' }}> <TouchableOpacity onPress={() => this.props.navigation.navigate('Profile')}>
{this.state.full_name} <Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center' }}>
</Text> {this.state.full_name}
</TouchableOpacity> </Text>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Profile')}> </TouchableOpacity>
<Text style={{ fontFamily: 'Gotham-Light', color: '#838383', fontSize: 12, textAlign: 'center', top: 2 }}>{i18n.t('Viewprofil')}</Text> <TouchableOpacity onPress={() => this.props.navigation.navigate('Profile')}>
</TouchableOpacity> <Text style={{ fontFamily: 'Gotham-Light', color: '#838383', fontSize: 12, textAlign: 'center', top: 2 }}>{i18n.t('Viewprofil')}</Text>
</TouchableOpacity>
</View>
</View> </View>
</View>
{
{ this.props.set_card === false ? (
this.props.set_card === false ? ( <View style={{ marginTop: 65 }}>
<View style={{ marginTop: 65 }}> <View style={{ flex: 1, backgroundColor: 'grey', height: 250, borderRadius: 20, marginRight: 10, marginLeft: 10, justifyContent: 'center' }}>
<View style={{ flex: 1, backgroundColor: 'grey', height: 250, borderRadius: 20, marginRight: 10, marginLeft: 10, justifyContent: 'center' }}> <View style={{ justifyContent: 'center' }}>
<View style={{ justifyContent: 'center' }}> <TouchableOpacity onPress={() => this.props.navigation.navigate('Card Activation', { cardNumber: this.state.card_number })}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Card Activation', { cardNumber: this.state.card_number })}> <View style={{ height: 50, borderRadius: 20, backgroundColor: 'white', marginRight: 20, marginLeft: 20, }}>
<View style={{ height: 50, borderRadius: 20, backgroundColor: 'white', marginRight: 20, marginLeft: 20, }}> <Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 15 }}>{i18n.t('Acitvatecard')}</Text>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 15 }}>{i18n.t('Acitvatecard')}</Text> </View>
</TouchableOpacity>
</View>
</View>
<View style={{ flex: 1, height: 250 }}>
<TouchableOpacity style={{ top: 10, marginLeft: 15, marginRight: 15, justifyContent: 'center' }} onPress={() => this.logout()}>
<View style={{ height: 40, borderRadius: 20, backgroundColor: '#CFB368', justifyContent: 'center' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center' }}>{i18n.t('logout')}</Text>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
</View> <View style={styles.v_logo}>
<View style={{ flex: 1, alignSelf: 'flex-start', marginTop: 20 }}>
</View> <Image resizeMode="contain" source={require('../assets/images/daun.png')} style={styles.logo}></Image>
<View style={{ flex: 1, height: 250 }}> </View>
<TouchableOpacity style={{ top: 10, marginLeft: 15, marginRight: 15, justifyContent: 'center' }} onPress={() => this.logout()}> <View style={{ flex: 1 }}>
<View style={{ height: 40, borderRadius: 20, backgroundColor: '#CFB368', justifyContent: 'center' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center' }}>{i18n.t('logout')}</Text> </View>
</View>
</TouchableOpacity>
<View style={styles.v_logo}>
<View style={{ flex: 1, alignSelf: 'flex-start', marginTop: 20 }}>
<Image resizeMode="contain" source={require('../assets/images/daun.png')} style={styles.logo}></Image>
</View>
<View style={{ flex: 1 }}>
</View> </View>
</View> </View>
</View> </View>
</View> ) : (
) : ( <View>
<View> <View style={styles.Card}>
<View style={styles.Card}>
<View style={styles.card}>
<View style={styles.card}> <View style={styles.card}>
{ <View style={styles.card}>
this.state.indicator ? ( {
<Card style={{ padding: 50, alignContent: 'center' }}> this.state.indicator ? (
<ActivityIndicator style={{ justifyContent: "center" }} size="large" color="#c9af6d" /> <Card style={{ padding: 50, alignContent: 'center' }}>
</Card> <ActivityIndicator style={{ justifyContent: "center" }} size="large" color="#c9af6d" />
) : ( </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>
{this.state.is_expired ? ( <View style={{ flex: 0.5 }}>
<Text style={{ fontSize: 10, textAlign: 'right', fontFamily: 'Gotham-Light', color: '#d34343' }}>Expired {this.state.expire_date}</Text> {this.state.is_expired ? (
) : ( <Text style={{ fontSize: 10, textAlign: 'right', fontFamily: 'Gotham-Light', color: '#d34343' }}>Expired {this.state.expire_date}</Text>
<Text style={{ fontSize: 10, textAlign: 'right', fontFamily: 'Gotham-Light' }}>{i18n.t('expired')} {this.state.expire_date}</Text> ) : (
) <Text style={{ fontSize: 10, textAlign: 'right', fontFamily: 'Gotham-Light' }}>{i18n.t('expired')} {this.state.expire_date}</Text>
} )
</View> }
</View> </View>
<View style={{ paddingHorizontal: 10 }}>
<Text style={{ textAlign: "center", fontSize: 30, color: '#c9af6d', fontFamily: 'Gotham-Black' }}>
{this.state.account_number}
</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={{ paddingHorizontal: 10 }}>
<Text style={{ fontSize: 14, fontFamily: 'Gotham-Black', color: 'gray' }}>IDR {this.state.balance}</Text> <Text style={{ textAlign: "center", fontSize: 30, color: '#c9af6d', fontFamily: 'Gotham-Black' }}>
{this.state.account_number}
</Text>
</View> </View>
</View> <View style={styles.line}></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('balance')}</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.balance}</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> <View style={styles.line2}></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('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> {
{ 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>
</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> */}
<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' }}>
<TouchableOpacity onPress={() => this.onClickClaimCredit()}>
<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> </View>
</TouchableOpacity> </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> */}
<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' }}>
<TouchableOpacity onPress={() => this.onClickClaimCredit()}>
<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> </View>
</View> </Card>) : (null)}
</Card>) : (null)} </>
</>
)
) }
} </View>
</View>
</View>
</View>
<TouchableOpacity style={styles.submitTopUp} activeOpacity={.5} onPress={() => this.props.navigation.navigate('TopUpInfo')}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center' }}>{i18n.t('topup')}</Text>
</TouchableOpacity>
<View style={{ padding: 10, height: 200, top: 10, margin: 10 }}>
<ImageBackground style={{ width: '100%', height: '100%', padding: 0, margin: 0 }} resizeMode='stretch' source={this.state.img_card ? { uri: this.state.img_card } : null}>
<View style={{ justifyContent: 'center' }}>
<Text style={{ fontFamily: 'Gotham-Black', margin: 15, fontSize: 14, color: '#c9af6d', top: 120 }}>
{this.state.account_number}
</Text>
</View> </View>
</ImageBackground>
</View>
<View style={{ marginLeft: 20, marginRight: 20, padding: 5 }}>
<View style={{ flex: 1, flexDirection: 'row', justifyContent: 'center', margin: 5 }}>
<TouchableOpacity style={{ marginBottom: 5, margin: 3 }} onPress={() => this.TransferBalance()} >
<Card style={{ height: 120, width: 155 }}>
<View style={{ height: 50, alignItems: 'center', padding: 10, flex: 1 }}>
<Image
style={{ height: 50, width: 50, justifyContent: 'center' }}
source={require('../assets/icon/4.png')}
/>
<Text style={{ fontFamily: 'Gotham-Black', textAlign: 'center', top: 5, fontSize: 14, color: '#838383' }}> {i18n.t('Transferbalance')}</Text>
</View>
</Card>
</TouchableOpacity>
<View style={{ width: 5 }}></View>
<TouchableOpacity style={{ marginBottom: 5, margin: 3 }} onPress={() => this.handleuseBalance()}>
<Card style={{ height: 120, width: 155 }}>
<View style={{ height: 50, alignItems: 'center', padding: 10, flex: 1 }}>
<Image
style={{ height: 50, width: 50, justifyContent: 'center' }}
source={require('../assets/icon/2.png')}
/>
<Text style={{ fontFamily: 'Gotham-Black', textAlign: 'center', top: 5, fontSize: 14, color: '#838383' }}> {i18n.t('Usebalancepoint')}</Text>
</View>
</Card>
</TouchableOpacity>
</View> </View>
<View style={{ flex: 1, flexDirection: 'row', marginBottom: 10, justifyContent: 'center' }}> <TouchableOpacity style={styles.submitTopUp} activeOpacity={.5} onPress={() => this.props.navigation.navigate('TopUpInfo')}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center' }}>{i18n.t('topup')}</Text>
<TouchableOpacity style={{ marginBottom: 5, margin: 4 }} onPress={() => this.props.navigation.navigate('Transaction History')} > </TouchableOpacity>
<Card style={{ height: 120, width: 155 }}> <View style={{ padding: 10, height: 200, top: 10, margin: 10 }}>
<View style={{ height: 50, alignItems: 'center', padding: 10, flex: 1 }}> <ImageBackground style={{ width: '100%', height: '100%', padding: 0, margin: 0 }} resizeMode='stretch' source={this.state.img_card ? { uri: this.state.img_card } : null}>
<Image <View style={{ justifyContent: 'center' }}>
style={{ height: 50, width: 50, justifyContent: 'center' }} <Text style={{ fontFamily: 'Gotham-Black', margin: 15, fontSize: 14, color: '#c9af6d', top: 120 }}>
source={require('../assets/icon/1.png')} {this.state.account_number}
/> </Text>
<Text style={{ fontFamily: 'Gotham-Black', flexDirection: 'row', textAlign: 'center', flexWrap: 'wrap', margin: 5, color: '#838383' }}> {i18n.t('Transactionhistory')}</Text> </View>
</View> </ImageBackground>
</Card>
</TouchableOpacity>
<View style={{ width: 5 }}></View>
<TouchableOpacity style={{ marginBottom: 5, margin: 4 }} onPress={() => this.props.navigation.navigate('Renewal')}>
<Card style={{ height: 120, width: 155 }}>
<View style={{ height: 50, alignItems: 'center', padding: 10, flex: 1 }}>
<Image
style={{ height: 50, width: 50, justifyContent: 'center' }}
source={require('../assets/icon/3.png')}
/>
<Text style={{ fontFamily: 'Gotham-Black', textAlign: 'center', top: 5, fontSize: 14, margin: 5, color: '#838383' }}> {i18n.t('Renewal')}</Text>
</View>
</Card>
</TouchableOpacity>
</View> </View>
<View style={{ flex: 1, flexDirection: 'row', justifyContent: 'center' }}> <View style={{ marginLeft: 20, marginRight: 20, padding: 5 }}>
{this.state.premium === false ? ( <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'center', margin: 5 }}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Upgrade Premium')} style={{ marginBottom: 20, marginRight: 5, marginLeft: 5 }}> <TouchableOpacity style={{ marginBottom: 5, margin: 3 }} onPress={() => this.TransferBalance()} >
<Card style={{ width: 200, paddingHorizontal: 10, paddingTop: 20, paddingBottom: 20 }}> <Card style={{ height: 120, width: 155 }}>
<View style={{ flex: 1, alignItems: 'center' }}> <View style={{ height: 50, alignItems: 'center', padding: 10, flex: 1 }}>
<MaterialIcons name="autorenew" size={30} color="gray" style={{ marginBottom: 10 }} /> <Image
<Text style={{ fontFamily: 'Gotham-Black', textAlign: 'center', fontSize: 14, color: '#838383' }}>{i18n.t('upgradePremium')}</Text> style={{ height: 50, width: 50, justifyContent: 'center' }}
source={require('../assets/icon/4.png')}
/>
<Text style={{ fontFamily: 'Gotham-Black', textAlign: 'center', top: 5, fontSize: 14, color: '#838383' }}> {i18n.t('Transferbalance')}</Text>
</View>
</Card>
</TouchableOpacity>
<View style={{ width: 5 }}></View>
<TouchableOpacity style={{ marginBottom: 5, margin: 3 }} onPress={() => this.handleuseBalance()}>
<Card style={{ height: 120, width: 155 }}>
<View style={{ height: 50, alignItems: 'center', padding: 10, flex: 1 }}>
<Image
style={{ height: 50, width: 50, justifyContent: 'center' }}
source={require('../assets/icon/2.png')}
/>
<Text style={{ fontFamily: 'Gotham-Black', textAlign: 'center', top: 5, fontSize: 14, color: '#838383' }}> {i18n.t('Usebalancepoint')}</Text>
</View> </View>
</Card> </Card>
</TouchableOpacity> </TouchableOpacity>
) : (
null
)}
</View>
</View>
<View style={{ flex: 1 }}>
<TouchableOpacity onPress={() => this.logout()}>
<View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', justifyContent: 'center', marginLeft: 20, marginRight: 20, marginBottom: 20, padding: 5, bottom: 5, top: 1 }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center' }}>{i18n.t('logout')}</Text>
</View> </View>
</TouchableOpacity> <View style={{ flex: 1, flexDirection: 'row', marginBottom: 10, justifyContent: 'center' }}>
<TouchableOpacity style={{ marginBottom: 5, margin: 4 }} onPress={() => this.props.navigation.navigate('Transaction History')} >
<Card style={{ height: 120, width: 155 }}>
<View style={{ height: 50, alignItems: 'center', padding: 10, flex: 1 }}>
<Image
style={{ height: 50, width: 50, justifyContent: 'center' }}
source={require('../assets/icon/1.png')}
/>
<Text style={{ fontFamily: 'Gotham-Black', flexDirection: 'row', textAlign: 'center', flexWrap: 'wrap', margin: 5, color: '#838383' }}> {i18n.t('Transactionhistory')}</Text>
</View>
</Card>
</TouchableOpacity>
<View style={{ width: 5 }}></View>
<TouchableOpacity style={{ marginBottom: 5, margin: 4 }} onPress={() => this.props.navigation.navigate('Renewal')}>
<Card style={{ height: 120, width: 155 }}>
<View style={{ height: 50, alignItems: 'center', padding: 10, flex: 1 }}>
<Image
style={{ height: 50, width: 50, justifyContent: 'center' }}
source={require('../assets/icon/3.png')}
/>
<Text style={{ fontFamily: 'Gotham-Black', textAlign: 'center', top: 5, fontSize: 14, margin: 5, color: '#838383' }}> {i18n.t('Renewal')}</Text>
</View>
</Card>
</TouchableOpacity>
</View>
<View style={{ flex: 1, flexDirection: 'row', justifyContent: 'center' }}>
{this.state.premium === false ? (
<TouchableOpacity onPress={() => this.props.navigation.navigate('Upgrade Premium')} style={{ marginBottom: 20, marginRight: 5, marginLeft: 5 }}>
<Card style={{ width: 200, paddingHorizontal: 10, paddingTop: 20, paddingBottom: 20 }}>
<View style={{ flex: 1, alignItems: 'center' }}>
<MaterialIcons name="autorenew" size={30} color="gray" style={{ marginBottom: 10 }} />
<Text style={{ fontFamily: 'Gotham-Black', textAlign: 'center', fontSize: 14, color: '#838383' }}>{i18n.t('upgradePremium')}</Text>
</View>
</Card>
</TouchableOpacity>
) : (
null
)}
</View>
</View>
<View style={{ flex: 1 }}>
<TouchableOpacity onPress={() => this.logout()}>
<View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', justifyContent: 'center', marginLeft: 20, marginRight: 20, marginBottom: 20, padding: 5, bottom: 5, top: 1 }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center' }}>{i18n.t('logout')}</Text>
</View>
</TouchableOpacity>
</View>
</View> </View>
</View> )
) }
}
<View style={{ flex: 1, marginBottom: 20, marginTop: 25 }}>
<View style={{ flex: 1, marginBottom: 20, marginTop: 25 }}> <Text style={{ color: 'grey', fontSize: 12, textAlign: 'center' }}>Version {Constants.manifest.version} Build {Constants.manifest.extra.buildNumber}</Text>
<Text style={{ color: 'grey', fontSize: 12, textAlign: 'center' }}>Version {Constants.manifest.version} Build {Constants.manifest.extra.buildNumber}</Text> <Text style={{ color: 'grey', fontSize: 12, textAlign: 'center' }}>{Constants.manifest.extra.remarks}</Text>
<Text style={{ color: 'grey', fontSize: 12, textAlign: 'center' }}>{Constants.manifest.extra.remarks}</Text> </View>
</View> </ScrollView>
</ScrollView>
</View >
</View > )
) } catch (error) {
Alert.alert('Error : ' + error)
}
} }
} }
...@@ -627,9 +687,9 @@ const mapDispatchToProps = (dispacth) => { ...@@ -627,9 +687,9 @@ const mapDispatchToProps = (dispacth) => {
type: ActionType.SET_ACCOUNT_NUMBER, type: ActionType.SET_ACCOUNT_NUMBER,
data: { data: {
card_number: setCardNumberProps.card_number, card_number: setCardNumberProps.card_number,
} }
}), }),
} }
} }
export default connect(mapStateToProps, mapDispatchToProps)(Account); export default connect(mapStateToProps, mapDispatchToProps)(Account);
......
import React from 'react'; import React from 'react';
import { View, Text, StyleSheet, Dimensions } from 'react-native'; import { View, Text, StyleSheet, Dimensions, Alert } from 'react-native';
import { Image } from 'react-native-elements'; import { Image } from 'react-native-elements';
import Axios from 'axios'; import Axios from 'axios';
import { TouchableOpacity, ScrollView } from 'react-native-gesture-handler'; import { TouchableOpacity, ScrollView } from 'react-native-gesture-handler';
...@@ -20,53 +20,68 @@ export default class NewsDetail extends React.Component { ...@@ -20,53 +20,68 @@ export default class NewsDetail extends React.Component {
} }
componentDidMount() { componentDidMount() {
const screenWidth = Math.round(Dimensions.get('window').width); try {
const statusBarHeight = getStatusBarHeight(); const screenWidth = Math.round(Dimensions.get('window').width);
this.setState({ const statusBarHeight = getStatusBarHeight();
image_height: screenWidth, this.setState({
statusbar_height: statusBarHeight image_height: screenWidth,
}) statusbar_height: statusBarHeight
this.get_news_detail(this.props.route.params.slug) })
this.get_news_detail(this.props.route.params.slug)
} catch (error) {
Alert.alert('Error', + error)
}
} }
get_news_detail(slug) { get_news_detail(slug) {
Axios.get('https://excelsocrm.ravintoladev.com/cms/v2/detail/' + slug).then(res => { try {
const detail = res.data; Axios.get('https://excelsocrm.ravintoladev.com/cms/v2/detail/' + slug).then(res => {
this.setState({ const detail = res.data;
title: detail.title, this.setState({
subtitle: detail.subtitle, title: detail.title,
image: detail.content_image, subtitle: detail.subtitle,
content: detail.content, image: detail.content_image,
}) content: detail.content,
}) })
})
} catch (error) {
Alert.alert('Error:'+ error)
}
} }
render() { render() {
// console.log(this.state.content) // console.log(this.state.content)
return ( try {
<View style={styles.container}> return (
<MyStatusBar /> <View style={styles.container}>
<ScrollView style={styles.body}> <MyStatusBar />
<View style={styles.image_container(this.state.image_height)}> <ScrollView style={styles.body}>
<Image style={styles.image(this.state.image_height)} source={this.state.image ? { uri: this.state.image } : null} /> <View style={styles.image_container(this.state.image_height)}>
</View> <Image style={styles.image(this.state.image_height)} source={this.state.image ? { uri: this.state.image } : null} />
<View style={styles.content}> </View>
<Text style={styles.title}>{this.state.title}</Text> <View style={styles.content}>
<View style={{ backgroundColor: '#adadad', height: 1.5, flex: 1, marginBottom: 5 }} /> <Text style={styles.title}>{this.state.title}</Text>
<HTML html={this.state.content} tagsStyles={{ <View style={{ backgroundColor: '#adadad', height: 1.5, flex: 1, marginBottom: 5 }} />
p: { fontSize: 12, color: '#838383', fontFamily: 'Gotham-Light' }, <HTML html={this.state.content} tagsStyles={{
blockquote: { backgroundColor: "#f1f1f1", padding: 12, paddingBottom: 0, marginTop: 0 }, p: { fontSize: 12, color: '#838383', fontFamily: 'Gotham-Light' },
li: { fontSize: 12, color: '#838383', fontFamily: 'Gotham-Light', marginBottom : 0 }, blockquote: { backgroundColor: "#f1f1f1", padding: 12, paddingBottom: 0, marginTop: 0 },
ul: { fontSize: 12, color: '#838383', fontFamily: 'Gotham-Light', marginVertical: 5, marginBottom : -10 }, li: { fontSize: 12, color: '#838383', fontFamily: 'Gotham-Light', marginBottom : 0 },
ul: { fontSize: 12, color: '#838383', fontFamily: 'Gotham-Light', marginVertical: 5, marginBottom : -10 },
}}
ignoredTags={['br']} }}
ignoredStyles={['font-family','&nbsp;', '&amp;']} /> ignoredTags={['br']}
</View> ignoredStyles={['font-family','&nbsp;', '&amp;']} />
</ScrollView> </View>
</View> </ScrollView>
) </View>
)
} catch (error) {
Alert.alert('Error' + error)
}
} }
} }
......
...@@ -18,91 +18,111 @@ class RewardsList extends React.Component { ...@@ -18,91 +18,111 @@ class RewardsList extends React.Component {
componentDidMount() { componentDidMount() {
// console.log("INI YA REWARD URL :"+this.props.BASE_URL) // console.log("INI YA REWARD URL :"+this.props.BASE_URL)
this.getRewardsList()
this._unsubscribe = this.props.navigation.addListener('focus', () => {
this.setState({
indicator: true
})
this.getRewardsList()
}); try {
this.getRewardsList()
this._unsubscribe = this.props.navigation.addListener('focus', () => {
this.setState({
indicator: true
})
this.getRewardsList()
});
} catch (error) {
Alert.alert('Error : ', + error)
}
} }
componentWillUnmount() { componentWillUnmount() {
try {
this._unsubscribe() this._unsubscribe()
} catch (error) {
Alert.alert('Error : ' + error);
}
} }
getRewardsList() { getRewardsList() {
let params = Object.assign(requestParams,{ try {
session_id: this.props.session_id, let params = Object.assign(requestParams,{
}) session_id: this.props.session_id,
Axios.post(this.props.BASE_URL+'crm/v2/reward/get_list', params).then(res => { })
let data = res.data.rewards Axios.post(this.props.BASE_URL+'crm/v2/reward/get_list', params).then(res => {
// console.log(data) let data = res.data.rewards
data.map((item, key) => { // console.log(data)
// console.log(item.expire_time) data.map((item, key) => {
item.expire_time = moment(item.expire_time).format("DD MMMM YYYY") // console.log(item.expire_time)
}) item.expire_time = moment(item.expire_time).format("DD MMMM YYYY")
// console.log(data) })
this.setState({ // console.log(data)
rewardsList: data, this.setState({
indicator: false rewardsList: data,
indicator: false
})
}).catch(error => {
let response = error.response.data;
Alert.alert(response.status, response.msg);
}) })
} catch (error) {
}).catch(error => { Alert.alert('Error : ' + error);
let response = error.response.data; }
Alert.alert(response.status, response.msg);
})
} }
render() { render() {
return ( try {
<View style={styles.container}> return (
<StatusBar backgroundColor='#CFB368' /> <View style={styles.container}>
<View style={styles.header}> <StatusBar backgroundColor='#CFB368' />
<Text style={{ color: 'white', textAlign: 'center', fontSize: 20, fontFamily: 'Gotham-Black' }}>{i18n.t('titlerewardhistory')}</Text> <View style={styles.header}>
</View> <Text style={{ color: 'white', textAlign: 'center', fontSize: 20, fontFamily: 'Gotham-Black' }}>{i18n.t('titlerewardhistory')}</Text>
<ScrollView style={styles.body}> </View>
{ <ScrollView style={styles.body}>
this.state.indicator ? (<ActivityIndicator style={{ top: 20, justifyContent: "center" }} size="large" color="#c9af6d" />) : ( {
this.state.rewardsList.length ? ( this.state.indicator ? (<ActivityIndicator style={{ top: 20, justifyContent: "center" }} size="large" color="#c9af6d" />) : (
this.state.rewardsList.map((item, key) => ( this.state.rewardsList.length ? (
<TouchableOpacity key={key} onPress={() => this.props.navigation.navigate('Reward Detail', { rewardId: item.id })}> this.state.rewardsList.map((item, key) => (
<View style={{ alignItems: 'center' }}> <TouchableOpacity key={key} onPress={() => this.props.navigation.navigate('Reward Detail', { rewardId: item.id })}>
<Card style={{ padding: 5, margin: 5 }}> <View style={{ alignItems: 'center' }}>
<View> <Card style={{ padding: 5, margin: 5 }}>
<Image source={{ uri: item.reward.title_image }} <View>
resizeMethod="resize" <Image source={{ uri: item.reward.title_image }}
resizeMode='cover' resizeMethod="resize"
style={{ height: 100, width: '100%' }} /> resizeMode='cover'
</View> style={{ height: 100, width: '100%' }} />
<View style={{ flex: 1, flexDirection: 'row', justifyContent: 'space-between', padding: 10 }}>
<View style={{ flex: 0.6 }}>
<Text style={{ textAlign: 'left', fontSize: 12, fontFamily: 'Gotham-Black', color: '#838383' }}>{item.reward.title}</Text>
<Text style={{ textAlign: 'left', fontSize: 12, fontFamily: 'Gotham-Light', color: '#838383' }}>{item.reward.subtitle}</Text>
</View> </View>
<View style={{ flex: 0.4 }}> <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'space-between', padding: 10 }}>
<Text style={{ textAlign: 'right', fontSize: 12, fontFamily: 'Gotham-Light', color: '#838383' }}>{i18n.t('expired')}</Text> <View style={{ flex: 0.6 }}>
<Text style={{ textAlign: 'right', fontSize: 12, fontFamily: 'Gotham-Light', color: '#838383' }}>{item.expire_time}</Text> <Text style={{ textAlign: 'left', fontSize: 12, fontFamily: 'Gotham-Black', color: '#838383' }}>{item.reward.title}</Text>
<Text style={{ textAlign: 'left', fontSize: 12, fontFamily: 'Gotham-Light', color: '#838383' }}>{item.reward.subtitle}</Text>
</View>
<View style={{ flex: 0.4 }}>
<Text style={{ textAlign: 'right', fontSize: 12, fontFamily: 'Gotham-Light', color: '#838383' }}>{i18n.t('expired')}</Text>
<Text style={{ textAlign: 'right', fontSize: 12, fontFamily: 'Gotham-Light', color: '#838383' }}>{item.expire_time}</Text>
</View>
</View> </View>
</View> </Card>
</Card> </View>
</TouchableOpacity>
))
) : (
<View style={{ justifyContent: 'center', alignItems: 'center', height: 100 }}>
<Text style={{ textAlign: 'left', fontSize: 12, fontFamily: 'Gotham-Light', color: 'grey' }}>{i18n.t('emptyvoucherlist')}</Text>
</View> </View>
</TouchableOpacity> ))
)) }
) : ( <TouchableOpacity style={{ marginVertical: 20 }} onPress={() => this.props.navigation.navigate('Reward History')}>
<View style={{ justifyContent: 'center', alignItems: 'center', height: 100 }}> <Text style={{ textAlign: 'center', color: '#CFB368', fontSize: 12, fontFamily: 'Gotham-Black' }}>{i18n.t('rewardhistory')}</Text>
<Text style={{ textAlign: 'left', fontSize: 12, fontFamily: 'Gotham-Light', color: 'grey' }}>{i18n.t('emptyvoucherlist')}</Text> </TouchableOpacity>
</View> <View style={{ height: 15 }} />
)) </ScrollView>
} </View>
<TouchableOpacity style={{ marginVertical: 20 }} onPress={() => this.props.navigation.navigate('Reward History')}> )
<Text style={{ textAlign: 'center', color: '#CFB368', fontSize: 12, fontFamily: 'Gotham-Black' }}>{i18n.t('rewardhistory')}</Text> } catch (error) {
</TouchableOpacity> Alert.alert('ERROR :' + error)
<View style={{ height: 15 }} /> }
</ScrollView>
</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