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