Commit 5c79fa43 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

transfer balance menambahkan field password

parent 4a25a8a9
import React from 'react';
import { View, Text, TextInput, StyleSheet, Button, Alert ,ScrollView,TouchableOpacity,Image } from 'react-native';
import { View, Text, TextInput, StyleSheet, Button, Alert, ScrollView, TouchableOpacity, Image } from 'react-native';
import Axios from 'axios';
import { connect } from 'react-redux';
import ActionType from '../redux/globalActionType';
import MyStatusBar from './MyStatusBar';
import i18n from 'i18n-js';
import Spinner from 'react-native-loading-spinner-overlay';
class TransferBalance extends React.Component {
constructor(props) {
super(props);
......@@ -19,7 +19,9 @@ class TransferBalance extends React.Component {
destination: "",
amount: "",
reference: "",
caretHidden:true,
password: "",
caretHidden: true,
spinner: false,
}
}
......@@ -32,7 +34,7 @@ class TransferBalance extends React.Component {
let params = {
session_id: this.props.session_id
}
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 => {
let data = res.data
// console.log('ini res nya : ' + data.kaspro_balance)
this.setState({
......@@ -46,93 +48,102 @@ class TransferBalance extends React.Component {
})
}).catch(error => {
let response = error.response.data;
// console.log(response.msg);
})
}
handleSend() {
this.setState({
spinner: true,
})
let params = {
"session_id": this.props.session_id,
"destination": this.state.destination,
"balance": this.state.amount,
"reference": this.state.reference
"reference": this.state.reference,
"password": this.state.password
}
// console.log(params);
Axios.post(this.props.BASE_URL+'crm/v2/card/transfer', params).then(res => {
Axios.post(this.props.BASE_URL + 'crm/v2/card/transfer', params).then(res => {
// console.log('ini res ' + JSON.stringify(res.data))
Alert.alert('Transaksi Berhasil')
Alert.alert('Sukses', 'Transaksi Berhasil')
this.props.navigation.goBack()
this.setState({
spinner: false,
})
}).catch(error => {
let response = error.response.data;
Alert.alert(response.msg);
Alert.alert('', response.msg);
this.setState({
spinner: false,
})
})
}
// handle() {
// let cardProps = {
// set_card: false
// }
// this.props.setCardactive(cardProps)
// console.log(this.props.set_card)
// }
render() {
return (
<View style={styles.container}>
<MyStatusBar />
<ScrollView>
<View style={{ flex: 3 }}>
<View style={{ flex: 1, margin: 20,top:20 }}>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3 }}>{i18n.t('phone')}</Text>
<TextInput style={{ height: 40, borderWidth: 1, padding: 5, margin: 10, borderRadius: 10, borderColor: 'grey', fontFamily: 'Gotham-Black', textAlign: 'center', color: 'grey', fontWeight: 'bold', fontSize: 20 }}
onChangeText={(destination) => this.setState({ destination })}
value={this.state.destination}
keyboardType='number-pad'
caretHidden={this.state.caretHidden}
onFocus={() => this.setState({caretHidden: false})}/>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3 }}>{i18n.t('amount')}</Text>
<TextInput style={{ height: 40, borderWidth: 1, padding: 5, margin: 10, borderRadius: 10, borderColor: 'grey', fontFamily: 'Gotham-Black', textAlign: 'center', color: 'grey', fontWeight: 'bold', fontSize: 20 }}
onChangeText={(amount) => this.setState({ amount })}
value={this.state.amount}
keyboardType='number-pad'
caretHidden={this.state.caretHidden}
onFocus={() => this.setState({caretHidden: false})} />
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3 }}>{i18n.t('currentbalance')}</Text>
<TextInput style={{ height: 40, borderWidth: 1, padding: 5, margin: 10, borderRadius: 10, borderColor: 'grey', fontFamily: 'Gotham-Black', textAlign: 'center', color: 'grey', fontWeight: 'bold', fontSize: 20 }}
onChangeText={(no_tlp) => this.setState({ no_tlp })}
editable={false}
caretHidden={this.state.caretHidden}
onFocus={() => this.setState({caretHidden: false})}>
{this.state.balance}
</TextInput>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3 }}>{i18n.t('message')}</Text>
<TextInput style={{ height: 100, borderWidth: 1, padding: 5, margin: 10, borderRadius: 10, borderColor: 'grey', fontFamily: 'Gotham-Black', textAlign: 'center', color: 'grey', fontWeight: 'bold', fontSize: 20 }}
onChangeText={(reference) => this.setState({ reference })}
value={this.state.reference}
caretHidden={this.state.caretHidden}
onFocus={() => this.setState({caretHidden: false})}>
</TextInput>
</View>
</View>
<View style={{ flex: 2 }}>
<View style={{ flex: 1 }}>
<View style={{ flex: 1, flexDirection: 'row', top: 10, margin: 5,marginBottom:20,marginLeft:20,marginRight:20}}>
<View style={{ flex: 1, margin: 5 }}>
<TouchableOpacity title="Edit" onPress={() => this.handleSend()}>
<View style={{ height: 40, borderRadius: 20, backgroundColor: '#CFB368',marginRight:40,marginLeft:40,justifyContent:'center'}}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 19, textAlign: 'center', margin: 20 }}>{i18n.t('save')}</Text>
<Spinner
visible={this.state.spinner}
textContent={'Loading...'}
textStyle={styles.spinnerTextStyle}
/>
<MyStatusBar />
<ScrollView>
<View style={{ flex: 3 }}>
<View style={{ flex: 1, margin: 20, top: 20 }}>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3 }}>{i18n.t('phone')}</Text>
<TextInput style={{ height: 40, borderWidth: 1, padding: 5, margin: 10, borderRadius: 10, borderColor: 'grey', fontFamily: 'Gotham-Black', textAlign: 'center', color: 'grey', fontWeight: 'bold', fontSize: 20 }}
onChangeText={(destination) => this.setState({ destination })}
value={this.state.destination}
keyboardType='number-pad'
caretHidden={this.state.caretHidden}
onFocus={() => this.setState({ caretHidden: false })} />
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3 }}>{i18n.t('amount')}</Text>
<TextInput style={{ height: 40, borderWidth: 1, padding: 5, margin: 10, borderRadius: 10, borderColor: 'grey', fontFamily: 'Gotham-Black', textAlign: 'center', color: 'grey', fontWeight: 'bold', fontSize: 20 }}
onChangeText={(amount) => this.setState({ amount })}
value={this.state.amount}
keyboardType='number-pad'
caretHidden={this.state.caretHidden}
onFocus={() => this.setState({ caretHidden: false })} />
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3 }}>{i18n.t('currentbalance')}</Text>
<TextInput style={{ height: 40, borderWidth: 1, padding: 5, margin: 10, borderRadius: 10, borderColor: 'grey', fontFamily: 'Gotham-Black', textAlign: 'center', color: 'grey', fontWeight: 'bold', fontSize: 20 }}
editable={false}
caretHidden={this.state.caretHidden}
onFocus={() => this.setState({ caretHidden: false })}>
{this.state.balance}
</TextInput>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3 }}>{i18n.t('password')}</Text>
<TextInput style={{ height: 40, borderWidth: 1, padding: 5, margin: 10, borderRadius: 10, borderColor: 'grey', fontFamily: 'Gotham-Black', textAlign: 'center', color: 'grey', fontWeight: 'bold', fontSize: 20 }}
onChangeText={(password) => this.setState({ password })}
editable={true}
caretHidden={this.state.caretHidden}
secureTextEntry={true}
onFocus={() => this.setState({ caretHidden: false })}>
</TextInput>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3 }}>{i18n.t('message')}</Text>
<TextInput style={{ height: 100, borderWidth: 1, padding: 5, margin: 10, borderRadius: 10, borderColor: 'grey', fontFamily: 'Gotham-Black', textAlign: 'center', color: 'grey', fontWeight: 'bold', fontSize: 20 }}
onChangeText={(reference) => this.setState({ reference })}
value={this.state.reference}
caretHidden={this.state.caretHidden}
onFocus={() => this.setState({ caretHidden: false })}>
</TextInput>
</View>
</View>
<View style={{ flex: 2 }}>
<View style={{ flex: 1 }}>
<View style={{ flex: 1, flexDirection: 'row', top: 10, margin: 5, marginBottom: 20, marginLeft: 20, marginRight: 20 }}>
<View style={{ flex: 1, margin: 5 }}>
<TouchableOpacity style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', marginRight: 40, marginLeft: 40, justifyContent: 'center' }} onPress={() => this.handleSend()}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 19, textAlign: 'center', margin: 20 }}>{i18n.t('save')}</Text>
</TouchableOpacity>
</View>
</View>
</TouchableOpacity>
</View>
</View>
</View>
</ScrollView>
</View>
</ScrollView>
</View>
)
}
}
......@@ -198,7 +209,6 @@ const mapStateToProps = (state) => {
}
const mapDispatchToProps = (dispacth) => {
console.log(dispacth)
return {
setCardactive: (cardProps) => dispacth({
type: ActionType.SET_CARD,
......
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