Commit 3b96fe36 authored by Afid's avatar Afid

renew until dapat dari server sekarang

parent 06909b82
import React from 'react';
import { View, Text, StyleSheet, Button, Alert, TouchableOpacity } from 'react-native';
import { View, Text, StyleSheet, Button, Alert, TouchableOpacity, ActivityIndicator } from 'react-native';
import { connect } from 'react-redux';
import Axios from 'axios';
import MyStatusBar from './MyStatusBar';
import i18n from 'i18n-js';
import Toast from 'react-native-tiny-toast';
import Spinner from 'react-native-loading-spinner-overlay';
import moment from 'moment'
class Renewal extends React.Component {
constructor(props) {
super(props);
......@@ -16,6 +18,8 @@ class Renewal extends React.Component {
card_number: "",
biaya_renewal: "100.000",
renew_until: "",
indicator: true,
spinner: false,
}
}
......@@ -43,19 +47,22 @@ class Renewal extends React.Component {
}
_renewal() {
this.setState({spinner: true})
let params = {
session_id: this.props.session_id
}
// console.log(params);
Axios.post(this.props.BASE_URL+'crm/v2/card/renewal', params).then(res => {
Axios.post(this.props.BASE_URL + 'crm/v2/card/renewal', params).then(res => {
// console.log('ini res ' + JSON.stringify(res.data))
this._getProfile();
Toast.show(i18n.t('successRenewal'))
this.props.navigation.navigate('Home', { screen: 'ACCOUNT' });
this.setState({spinner: false})
}).catch(error => {
let response = error.response.data;
// console.log(response.msg)
Alert.alert('', response.msg);
this.setState({spinner: false})
})
}
......@@ -64,26 +71,20 @@ class Renewal extends React.Component {
session_id: this.props.session_id
}
Axios.post(this.props.BASE_URL+'crm/v2/member/get_profile', params).then(res => {
// console.log('ini res ' + JSON.stringify(res.data))
Axios.post(this.props.BASE_URL + 'crm/v2/member/get_profile', params).then(res => {
console.log('ini res ' + JSON.stringify(res.data))
const dataCard = res.data
let balance = dataCard.kaspro_balance
let expired = dataCard.expire_date
let c_renew_until = dataCard.expire_date
var date_string = c_renew_until
var date_arr = date_string.split('-');
var date = new Date(date_arr[0], date_arr[1], date_arr[2]);
let renew = dataCard.renew_until
date.setFullYear(date.getFullYear() + 1);
let date_nextyear_string = moment([date.getFullYear(),date.getMonth(), date.getDate()]).month(date.getMonth() - 1).format("YYYY-MM-DD")
// console.log("INI YA : " + date_nextyear_string)
this.setState({
current_balance: balance,
expired: expired,
renew_until: date_nextyear_string
renew_until: renew,
indicator: false,
})
}).catch(error => {
......@@ -98,6 +99,13 @@ class Renewal extends React.Component {
{/* <View style={styles.header}> */}
{/* <Text style={{ textAlign: 'center', margin: 20, fontSize: 25, alignSelf: 'center' }}>Renewal</Text> */}
{/* </View> */}
<Spinner
visible={this.state.spinner}
textContent={'Loading...'}
textStyle={styles.spinnerTextStyle}
/>
{
this.state.indicator ? (<ActivityIndicator style={{ top: 20, justifyContent: "center" }} size="large" color="#c9af6d" />) : (
<View style={styles.body}>
<View style={styles.cont_curent_balance}>
<View style={styles.current_balance}>
......@@ -141,6 +149,8 @@ class Renewal extends React.Component {
</View>
</TouchableOpacity>
</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