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,12 +51,14 @@ class Account extends React.Component {
old_balance_claimed: false,
old_balance: 0,
is_expired: false,
card_number:"",
card_number: "",
}
}
componentDidMount() {
try {
this._getProfile()
this._unsubscribe = this.props.navigation.addListener('focus', () => {
this.setState({
......@@ -64,13 +66,23 @@ class Account extends React.Component {
})
this._getProfile()
});
} catch (error) {
Alert.alert('Error' + error)
}
}
componentWillUnmount() {
try {
this._unsubscribe();
} catch (error) {
Alert.alert('Error : ' + error)
}
}
_getPermissions = async () => {
try {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
Alert.alert('Akses tidak dizinkan!')
......@@ -80,8 +92,13 @@ class Account extends React.Component {
} else {
this._getCurrentPosisition()
}
} catch (error) {
Alert.alert('Error : ' + error)
}
}
_getCurrentPosisition = async () => {
try {
this.setState({
spinner: true,
})
......@@ -98,18 +115,28 @@ class Account extends React.Component {
})
this._getProfile()
} catch (error) {
Alert.alert('Error: + ', error)
}
}
logout() {
try {
let configProps = {
session_id: ''
}
this.props.setConfig(configProps);
this.props.navigation.replace('Login');
} catch (error) {
Alert.alert('ERROR : ' + error)
}
}
onClickClaimCredit() {
try {
Alert.alert(
"",
"Are you sure want to claim credit ?",
......@@ -125,10 +152,16 @@ class Account extends React.Component {
],
{ cancelable: false },
)
} catch (error) {
Alert.alert('Error: ' + error)
}
}
handleClaimCredit() {
let params = Object.assign(requestParams,{
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 => {
......@@ -137,10 +170,16 @@ class Account extends React.Component {
let response = error.response.data
Alert.alert(error, response.msg)
})
} catch (error) {
Alert.alert('Error : '+ error)
}
}
_getProfile() {
let params = Object.assign(requestParams,{
try {
let params = Object.assign(requestParams, {
session_id: this.props.session_id,
lat: this.state.my_lat,
long: this.state.my_long,
......@@ -148,7 +187,7 @@ class Account extends React.Component {
})
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
console.log(dataCard)
let email = dataCard.email
......@@ -213,10 +252,16 @@ class Account extends React.Component {
// Alert.alert('',response.msg);
Toast.show(response.msg)
})
} catch (error) {
Alert.alert('Error :' + error)
}
}
TransferBalance() {
try {
if (this.state.premium === false) {
Alert.alert(
'Akun Belum Premium',
......@@ -229,10 +274,16 @@ class Account extends React.Component {
} else {
this.props.navigation.navigate('Transfer Balance');
}
} catch (error) {
Alert.alert('Error : ' + error)
}
}
handleuseBalance() {
let params = Object.assign(requestParams,{
try {
let params = Object.assign(requestParams, {
session_id: this.props.session_id,
})
Axios.post(this.props.BASE_URL + 'crm/v2/point/check', params).then(res => {
......@@ -245,13 +296,18 @@ class Account extends React.Component {
let response = error.response.data
Alert.alert(error, response.msg)
})
} catch (error) {
Alert.alert('Error:' + error)
}
}
render() {
try {
const navigation = this.props.navigation
return (
<View style={styles.container}>
<ScrollView style={{paddingTop: StatusBar.currentHeight}}>
<ScrollView style={{ paddingTop: StatusBar.currentHeight }}>
<View style={{ flex: 1, height: 90 }}>
<View style={{ alignSelf: 'center' }}>
......@@ -360,7 +416,7 @@ class Account extends React.Component {
{
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' }}>
<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>
......@@ -371,7 +427,7 @@ class Account extends React.Component {
<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={''} />
<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' }}>
......@@ -489,6 +545,10 @@ class Account extends React.Component {
</View >
)
} catch (error) {
Alert.alert('Error : ' + error)
}
}
}
......
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 Axios from 'axios';
import { TouchableOpacity, ScrollView } from 'react-native-gesture-handler';
......@@ -20,6 +20,7 @@ export default class NewsDetail extends React.Component {
}
componentDidMount() {
try {
const screenWidth = Math.round(Dimensions.get('window').width);
const statusBarHeight = getStatusBarHeight();
this.setState({
......@@ -27,9 +28,14 @@ export default class NewsDetail extends React.Component {
statusbar_height: statusBarHeight
})
this.get_news_detail(this.props.route.params.slug)
} catch (error) {
Alert.alert('Error', + error)
}
}
get_news_detail(slug) {
try {
Axios.get('https://excelsocrm.ravintoladev.com/cms/v2/detail/' + slug).then(res => {
const detail = res.data;
this.setState({
......@@ -39,11 +45,16 @@ export default class NewsDetail extends React.Component {
content: detail.content,
})
})
} catch (error) {
Alert.alert('Error:'+ error)
}
}
render() {
// console.log(this.state.content)
try {
return (
<View style={styles.container}>
<MyStatusBar />
......@@ -67,6 +78,10 @@ export default class NewsDetail extends React.Component {
</ScrollView>
</View>
)
} catch (error) {
Alert.alert('Error' + error)
}
}
}
......
......@@ -18,6 +18,8 @@ class RewardsList extends React.Component {
componentDidMount() {
// console.log("INI YA REWARD URL :"+this.props.BASE_URL)
try {
this.getRewardsList()
this._unsubscribe = this.props.navigation.addListener('focus', () => {
this.setState({
......@@ -26,13 +28,23 @@ class RewardsList extends React.Component {
this.getRewardsList()
});
} catch (error) {
Alert.alert('Error : ', + error)
}
}
componentWillUnmount() {
try {
this._unsubscribe()
} catch (error) {
Alert.alert('Error : ' + error);
}
}
getRewardsList() {
try {
let params = Object.assign(requestParams,{
session_id: this.props.session_id,
})
......@@ -53,9 +65,14 @@ class RewardsList extends React.Component {
let response = error.response.data;
Alert.alert(response.status, response.msg);
})
} catch (error) {
Alert.alert('Error : ' + error);
}
}
render() {
try {
return (
<View style={styles.container}>
<StatusBar backgroundColor='#CFB368' />
......@@ -103,6 +120,9 @@ class RewardsList extends React.Component {
</ScrollView>
</View>
)
} catch (error) {
Alert.alert('ERROR :' + error)
}
}
}
......
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