Commit 9ed8d5f5 authored by Trisno's avatar Trisno

add toast and alert

parent 95c37ed1
...@@ -4,6 +4,7 @@ import { connect } from 'react-redux'; ...@@ -4,6 +4,7 @@ import { connect } from 'react-redux';
import Axios from 'axios'; import Axios from 'axios';
import MyStatusBar from './MyStatusBar'; import MyStatusBar from './MyStatusBar';
import i18n from 'i18n-js'; import i18n from 'i18n-js';
import Toast from 'react-native-tiny-toast';
class Renewal extends React.Component { class Renewal extends React.Component {
constructor(props) { constructor(props) {
...@@ -21,6 +22,23 @@ class Renewal extends React.Component { ...@@ -21,6 +22,23 @@ class Renewal extends React.Component {
this._getProfile(); this._getProfile();
} }
_handleRenewal() {
Alert.alert(
"Renewal",
"Are you sure want to renewal ?",
[
{
text: 'No',
onPress: () => console.log('Cancel Renewal'),
style: 'cancel',
},
{
text: 'Yes', onPress: () => this._renewal()
},
],
{ cancelable: false },
)
}
_renewal() { _renewal() {
let params = { let params = {
...@@ -30,11 +48,12 @@ class Renewal extends React.Component { ...@@ -30,11 +48,12 @@ class Renewal extends React.Component {
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/card/renewal', params).then(res => { Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/card/renewal', params).then(res => {
// console.log('ini res ' + JSON.stringify(res.data)) // console.log('ini res ' + JSON.stringify(res.data))
this._getProfile(); this._getProfile();
this.props.navigation.navigate('HOME',{screen:'Account'}); Toast.show('Successfully Renewal')
this.props.navigation.navigate('Home', { screen: 'ACCOUNT' });
}).catch(error => { }).catch(error => {
let response = error.response.data; let response = error.response.data;
// console.log(response.msg) // console.log(response.msg)
Alert.alert('',response.msg); Alert.alert('', response.msg);
}) })
} }
...@@ -54,11 +73,11 @@ class Renewal extends React.Component { ...@@ -54,11 +73,11 @@ class Renewal extends React.Component {
var date_string = c_renew_until var date_string = c_renew_until
var date_arr = date_string.split('-'); var date_arr = date_string.split('-');
var date = new Date(date_arr[0], date_arr[1], date_arr[2]); var date = new Date(date_arr[0], date_arr[1], date_arr[2]);
date.setFullYear(date.getFullYear() + 1); date.setFullYear(date.getFullYear() + 1);
let date_nextyear_string = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() let date_nextyear_string = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate()
console.log("INI YA : " + date_nextyear_string) console.log("INI YA : " + date_nextyear_string)
this.setState({ this.setState({
current_balance: balance, current_balance: balance,
expired: expired, expired: expired,
...@@ -75,46 +94,46 @@ class Renewal extends React.Component { ...@@ -75,46 +94,46 @@ class Renewal extends React.Component {
<View style={styles.container}> <View style={styles.container}>
<MyStatusBar /> <MyStatusBar />
{/* <View style={styles.header}> */} {/* <View style={styles.header}> */}
{/* <Text style={{ textAlign: 'center', margin: 20, fontSize: 25, alignSelf: 'center' }}>Renewal</Text> */} {/* <Text style={{ textAlign: 'center', margin: 20, fontSize: 25, alignSelf: 'center' }}>Renewal</Text> */}
{/* </View> */} {/* </View> */}
<View style={styles.body}> <View style={styles.body}>
<View style={styles.cont_curent_balance}> <View style={styles.cont_curent_balance}>
<View style={styles.current_balance}> <View style={styles.current_balance}>
<Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color:'#CFB368' }}>{i18n.t('currentbalance')}</Text> <Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color: '#CFB368' }}>{i18n.t('currentbalance')}</Text>
</View> </View>
<View style={styles.value_current_balance}> <View style={styles.value_current_balance}>
<Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color:'gray' }}>IDR {this.state.current_balance}</Text> <Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color: 'gray' }}>IDR {this.state.current_balance}</Text>
</View> </View>
</View> </View>
<View style={styles.cont_curent_balance}> <View style={styles.cont_curent_balance}>
<View style={styles.current_balance}> <View style={styles.current_balance}>
<Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color:'#CFB368' }}>{i18n.t('renewalfees')}</Text> <Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color: '#CFB368' }}>{i18n.t('renewalfees')}</Text>
</View> </View>
<View style={styles.value_current_balance}> <View style={styles.value_current_balance}>
<Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color:'gray' }}>IDR {this.state.biaya_renewal}</Text> <Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color: 'gray' }}>IDR {this.state.biaya_renewal}</Text>
</View> </View>
</View> </View>
<View style={styles.cont_curent_balance}> <View style={styles.cont_curent_balance}>
<View style={styles.current_balance}> <View style={styles.current_balance}>
<Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color:'#CFB368' }}>{i18n.t('expired')}</Text> <Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color: '#CFB368' }}>{i18n.t('expired')}</Text>
</View> </View>
<View style={styles.value_current_balance}> <View style={styles.value_current_balance}>
<Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color:'gray' }}>{this.state.expired}</Text> <Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color: 'gray' }}>{this.state.expired}</Text>
</View> </View>
</View> </View>
<View style={styles.cont_curent_balance}> <View style={styles.cont_curent_balance}>
<View style={styles.current_balance}> <View style={styles.current_balance}>
<Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color:'#CFB368' }}>{i18n.t('renewuntil')}</Text> <Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color: '#CFB368' }}>{i18n.t('renewuntil')}</Text>
</View> </View>
<View style={styles.value_current_balance}> <View style={styles.value_current_balance}>
<Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color:'gray' }}>{this.state.renew_until}</Text> <Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color: 'gray' }}>{this.state.renew_until}</Text>
</View> </View>
</View> </View>
{/* <View style={styles.btn_renewal}> {/* <View style={styles.btn_renewal}>
<Button title="Renew" onPress={() => this._renewal()}></Button> <Button title="Renew" onPress={() => this._renewal()}></Button>
</View> */} </View> */}
<TouchableOpacity onPress={() => this._renewal()}> <TouchableOpacity onPress={() => this._handleRenewal()}>
<View style={styles.button}> <View style={styles.button}>
<Text style={{ color: 'white', fontSize: 16, textAlign: 'center', fontFamily: 'Gotham-Black' }}>{i18n.t('renew')}</Text> <Text style={{ color: 'white', fontSize: 16, textAlign: 'center', fontFamily: 'Gotham-Black' }}>{i18n.t('renew')}</Text>
</View> </View>
...@@ -139,32 +158,32 @@ const styles = StyleSheet.create({ ...@@ -139,32 +158,32 @@ const styles = StyleSheet.create({
marginTop: 12 marginTop: 12
}, },
cont_curent_balance: { cont_curent_balance: {
flex:0.2 flex: 0.2
}, },
current_balance: { current_balance: {
flex: 1, flex: 1,
// backgroundColor:'cyan', // backgroundColor:'cyan',
justifyContent:'center', justifyContent: 'center',
}, },
value_current_balance: { value_current_balance: {
flex: 1, flex: 1,
marginHorizontal:30, marginHorizontal: 30,
paddingHorizontal: 10, paddingHorizontal: 10,
paddingVertical : 5, paddingVertical: 5,
justifyContent:'center', justifyContent: 'center',
borderWidth:1, borderWidth: 1,
borderColor:'gray', borderColor: 'gray',
borderRadius:10, borderRadius: 10,
// backgroundColor:'maroon' // backgroundColor:'maroon'
}, },
button: { button: {
height: 40, height: 40,
borderRadius: 10, borderRadius: 10,
backgroundColor: '#CFB368', backgroundColor: '#CFB368',
justifyContent: 'center', justifyContent: 'center',
margin: 30, margin: 30,
padding: 5, padding: 5,
bottom: 5, bottom: 5,
}, },
}) })
......
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