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

transfer balance menambahkan field password

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