Commit 31ce1e2d authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

- memperbaiki bug token

- jika card number kosong editable true jika tidak maka editable false
parent 97e9badc
......@@ -48,7 +48,8 @@ class Account extends React.Component {
clickSettings: 0,
old_balance_claimed: false,
old_balance: 0,
is_expired: false
is_expired: false,
card_number:"",
}
}
......@@ -128,6 +129,7 @@ class Account extends React.Component {
}
Axios.post(this.props.BASE_URL + 'crm/v2/member/get_profile', params).then(res => {
console.log("INI DATANYA : " +JSON.stringify(res))
const dataCard = res.data
console.log(dataCard)
let email = dataCard.email
......@@ -142,6 +144,7 @@ class Account extends React.Component {
let old_balance_claimed = dataCard.old_balance_claimed
let old_balance = dataCard.old_balance
let is_expired = dataCard.is_expired
let card_number = dataCard.card_number
if (kaspro === "") {
......@@ -160,6 +163,11 @@ class Account extends React.Component {
let account_number = dataCard.card_number
let setCardNumberProps = {
card_number : account_number
}
this.props.setCardNumber(setCardNumberProps)
this.setState({
email: email,
points: point,
......@@ -174,7 +182,8 @@ class Account extends React.Component {
indicator: false,
old_balance_claimed: old_balance_claimed,
old_balance: old_balance,
is_expired: is_expired
is_expired: is_expired,
card_number:card_number
})
......@@ -253,7 +262,7 @@ class Account extends React.Component {
<View style={{ marginTop: 65 }}>
<View style={{ flex: 1, backgroundColor: 'grey', height: 250, borderRadius: 20, marginRight: 10, marginLeft: 10, justifyContent: 'center' }}>
<View style={{ justifyContent: 'center' }}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Card Activation')}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Card Activation',{ cardNumber: this.state.card_number })}>
<View style={{ height: 50, borderRadius: 20, backgroundColor: 'white', marginRight: 20, marginLeft: 20, }}>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 15 }}> {i18n.t('Acitvatecard')}</Text>
</View>
......@@ -598,6 +607,13 @@ const mapDispatchToProps = (dispacth) => {
set_card: cardProps.set_card,
}
}),
setCardNumber: (setCardNumberProps) => dispacth({
type: ActionType.SET_ACCOUNT_NUMBER,
data: {
card_number: setCardNumberProps.card_number,
}
}),
}
}
export default connect(mapStateToProps, mapDispatchToProps)(Account);
......
......@@ -14,48 +14,119 @@ class CardActivation extends React.Component {
session_id: "",
mobile_phone: "",
card_number: "",
card_nums: this.props.route.params.cardNumber,
token: "",
timer: 80,
timer: 3,
onclickToken: false,
onclick: false,
spinner: false,
caretHidden: true,
}
}
componentDidMount() {
console.log("INI CARD NUMBER" + this.props.card_number)
console.log("INI BASE_URL " + this.props.BASE_URL)
}
componentDidUpdate(prevProps) {
if (this.state.timer === 0) {
clearInterval(this.interval);
}
}
componentWillUnmount() {
clearInterval(this.interval);
}
handleToken() {
_getProfile() {
let params = {
session_id: this.props.session_id,
mobile_phone: this.state.mobile_phone
lat: this.state.my_lat,
long: this.state.my_long,
closest_outlet: 1
}
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/get_token', params).then(res => {
this.setState({
onclick: true
})
Alert.alert('Kami telah mengirimkan sms otp ke nomor anda!');
this.interval = setInterval(
() => this.setState((prevState) => ({ timer: prevState.timer - 1 })),
1000
);
Axios.post(this.props.BASE_URL + 'crm/v2/member/get_profile', params).then(res => {
console.log("INI DATANYA : " + JSON.stringify(res))
const dataCard = res.data
console.log(dataCard)
let email = dataCard.email
let point = dataCard.kaspro_point
let balance = dataCard.kaspro_balance
let img_card = dataCard.card_series_image
let member_since = dataCard.member_since
let expire = dataCard.expire_date
let premium = dataCard.kaspro_is_premium
let kaspro = dataCard.kaspro_account_number
let full_name = dataCard.name
let old_balance_claimed = dataCard.old_balance_claimed
let old_balance = dataCard.old_balance
let is_expired = dataCard.is_expired
let account_number = dataCard.card_number
this.setState({
onclick: true
email: email,
points: point,
img_card: img_card,
member_since: member_since,
balance: balance,
account_number: account_number,
img_card: img_card,
expire_date: expire,
premium: premium,
full_name: full_name,
indicator: false,
old_balance_claimed: old_balance_claimed,
old_balance: old_balance,
is_expired: is_expired,
})
}).catch(error => {
let response = error.response.data;
// const { navigation } = this.props
// let response = error.response.data
// session(response, navigation)
Alert.alert('',response.msg);
let response = error.response.data
// Alert.alert('',response.msg);
Toast.show(response.msg)
})
}
handleToken() {
if (this.state.mobile_phone == '') {
Alert.alert('', 'Masukan No telp ');
} else {
let params = {
session_id: this.props.session_id,
mobile_phone: this.state.mobile_phone
}
Axios.post(this.props.BASE_URL + 'crm/v2/get_token', params).then(res => {
this.setState({
onclick: true
})
Alert.alert('Kami telah mengirimkan sms otp ke nomor anda!');
this.interval = setInterval(
() => this.setState((prevState) => ({ timer: prevState.timer - 1 })),
1000
);
this.setState({
onclick: true
})
}).catch(error => {
let response = error.response.data;
// const { navigation } = this.props
// session(response, navigation)
Alert.alert('', response.msg);
})
}
}
ResendToken() {
this.setState({
spinner: true,
......@@ -64,14 +135,14 @@ class CardActivation extends React.Component {
session_id: this.props.session_id,
mobile_phone: this.state.mobile_phone
}
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/resend_token', params).then(res => {
Axios.post(this.props.BASE_URL + 'crm/v2/resend_token', params).then(res => {
this.setState({
spinner: false,
})
Alert.alert('Kami telah kembali mengirimkan sms otp ke nomor anda!');
this.setState({
timer: 80
timer: 3
})
this.interval = setInterval(
() => this.setState((prevState) => ({ timer: prevState.timer - 1 })),
......@@ -82,28 +153,76 @@ class CardActivation extends React.Component {
spinner: false,
})
let response = error.response.data;
Alert.alert('',response.msg);
Alert.alert('', response.msg);
})
}
handleActivate() {
this.setState({
spinner: true,
})
handlecardNumberNotnull() {
let params = {
session_id: this.props.session_id,
mobile_phone: this.state.mobile_phone,
card_number: this.state.card_number,
token: this.state.token
}
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/card/activate', params).then(res => {
console.log("INI PARAMS " + JSON.stringify(params))
Axios.post(this.props.BASE_URL + 'crm/v2/card/activate', params).then(res => {
let setCardNumberProps = {
card_number: ""
}
this.props.setCardNumber(setCardNumberProps)
Alert.alert(
"",
"Kartu anda berhasil di aktifkan",
[
{
text: "OK", onPress: () => {
this.setState({ spinner: false })
this.props.navigation.reset({
index: 0,
routes: [{ name: 'Home' }],
})
}
}
],
);
}).catch(error => {
let response = error.response.data;
Alert.alert(
'',
response.msg,
[
{ text: "OK", onPress: () => this.setState({ spinner: false }) }
],
);
})
}
handlecardNumbernull() {
let params = {
session_id: this.props.session_id,
mobile_phone: this.state.mobile_phone,
card_number: this.state.card_nums,
token: this.state.token
}
console.log("INI STATENYA " + this.state.card_nums)
console.log("INI PARAMS " + JSON.stringify(params))
Axios.post(this.props.BASE_URL + 'crm/v2/card/activate', params).then(res => {
let setCardNumberProps = {
card_number: ""
}
this.props.setCardNumber(setCardNumberProps)
Alert.alert(
"",
"",
"Kartu anda berhasil di aktifkan",
[
{ text: "OK", onPress: () =>
{
this.setState({spinner: false})
{
text: "OK", onPress: () => {
this.setState({ spinner: false })
this.props.navigation.reset({
index: 0,
routes: [{ name: 'Home' }],
......@@ -115,14 +234,27 @@ class CardActivation extends React.Component {
}).catch(error => {
let response = error.response.data;
Alert.alert(
'',
'',
response.msg,
[
{ text: "OK", onPress: () => this.setState({spinner: false}) }
{ text: "OK", onPress: () => this.setState({ spinner: false }) }
],
);
})
}
handleActivate() {
this.setState({
spinner: true,
})
if (this.props.card_number == '') {
this.handlecardNumberNotnull()
} else {
this.handlecardNumbernull()
}
}
render() {
......@@ -137,62 +269,84 @@ class CardActivation extends React.Component {
<View style={styles.form}>
<View style={styles.field_phone}>
<View style={{ flex: 1, margin: 10 }}>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 19, textAlign: 'center', marginBottom: 5 }}>{i18n.t('mobilePhone')}</Text>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 19, textAlign: 'center', marginBottom: 5 }}>{i18n.t('mobilePhone')}</Text>
<TextInput
style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 5, borderRadius: 10,textAlign:'center',fontFamily:'Gotham-Black',color:'grey', fontSize:16}}
style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 5, borderRadius: 10, textAlign: 'center', fontFamily: 'Gotham-Black', color: 'grey', fontSize: 16 }}
onChangeText={mobile_phone => this.setState({ mobile_phone })}
keyboardType='numeric'
value={this.state.mobile_phone}
caretHidden={this.state.caretHidden}
onFocus={() => this.setState({ caretHidden: false })}
/>
</View>
<View style={styles.button}>
<TouchableOpacity style={{top:25}} onPress={() => this.handleToken()}>
<View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', justifyContent: 'center' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 20, textAlign: 'center',margin:10 }}>Token</Text>
</View>
</TouchableOpacity>
{this.state.onclick == true ? (null) : (
<TouchableOpacity style={{ top: 25 }} onPress={() => this.handleToken()}>
<View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', justifyContent: 'center' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 20, textAlign: 'center', margin: 10 }}>Token</Text>
</View>
</TouchableOpacity>
)}
</View>
</View>
{
this.state.onclick === true ? (<Text style={{ textAlign: 'center',fontFamily:'Gotham-Black' }}> 0:{this.state.timer} </Text>) : (
this.state.onclick === true ? (<Text style={{ textAlign: 'center', fontFamily: 'Gotham-Black',color:'red' }}> 0:{this.state.timer} </Text>) : (
null
)
}
{
this.state.timer === 0 ? (
<TouchableOpacity onPress={() => this.ResendToken()}>
<View style={{ height: 40, borderRadius: 20, backgroundColor: '#CFB368', margin: 20, justifyContent: 'center' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 20, textAlign: 'center' }}>{i18n.t('resend')} Token</Text>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.ResendToken()}>
<View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', margin: 20, justifyContent: 'center' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 20, textAlign: 'center' }}>{i18n.t('resend')}</Text>
</View>
</TouchableOpacity>
) : (null)}
<View style={styles.field_email}>
<View style={{ flex: 1, margin: 10 }}>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 19, textAlign: 'center', marginBottom: 5 }}>{i18n.t('cardNumber')}</Text>
<TextInput
style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 5, borderRadius: 10,textAlign:'center',fontFamily:'Gotham-Black',color:'grey', fontSize:16}}
onChangeText={card_number => this.setState({ card_number })}
value={this.state.card_number}
keyboardType='numeric'
/>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 19, textAlign: 'center', marginBottom: 5 }}>{i18n.t('cardNumber')}</Text>
{this.state.card_nums == "" ? (
<TextInput
style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 5, borderRadius: 10, textAlign: 'center', fontFamily: 'Gotham-Black', color: 'grey', fontSize: 16 }}
onChangeText={card_number => this.setState({ card_number })}
keyboardType='numeric'
caretHidden={this.state.caretHidden}
onFocus={() => this.setState({ caretHidden: false })}
/>
) : (
<TextInput
style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 5, borderRadius: 10, textAlign: 'center', fontFamily: 'Gotham-Black', color: 'grey', fontSize: 16 }}
onChangeText={card_nums => this.setState({ card_nums })}
value={this.props.card_number}
editable={false}
caretHidden={this.state.caretHidden}
defaultValue={this.props.card_nums}
onFocus={() => this.setState({ caretHidden: false })}
/>
)}
</View>
</View>
<View style={styles.field_email}>
<View style={{ flex: 1, margin: 10 }}>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 19, textAlign: 'center', marginBottom: 5 }}>Token</Text>
<TextInput
style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 5, borderRadius: 10,textAlign:'center',fontFamily:'Gotham-Black',color:'grey', fontSize:16}}
style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 5, borderRadius: 10, textAlign: 'center', fontFamily: 'Gotham-Black', color: 'grey', fontSize: 16 }}
onChangeText={token => this.setState({ token })}
value={this.state.token}
keyboardType='numeric'
caretHidden={this.state.caretHidden}
onFocus={() => this.setState({ caretHidden: false })}
/>
</View>
</View>
<View style={styles.button}>
<TouchableOpacity onPress={() => this.handleActivate()}>
<View style={{ height: 40, borderRadius: 20, backgroundColor: '#CFB368', margin: 20, justifyContent: 'center' }}>
<View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', margin: 20, justifyContent: 'center' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 20, textAlign: 'center' }}>{i18n.t('activate')}</Text>
</View>
</TouchableOpacity>
......@@ -229,7 +383,6 @@ const styles = StyleSheet.create({
flexDirection: 'row'
},
button: {
height: 50,
margin: 10,
......@@ -240,9 +393,24 @@ const styles = StyleSheet.create({
const mapStateToProps = (state) => {
return {
session_id: state.session_id,
set_card: state.set_card
set_card: state.set_card,
card_number: state.card_number,
BASE_URL: state.BASE_URL,
}
}
const mapDispatchToProps = (dispacth) => {
return {
setCardNumber: (setCardNumberProps) => dispacth({
type: ActionType.SET_ACCOUNT_NUMBER,
data: {
card_number: setCardNumberProps.card_number,
}
}),
}
}
export default connect(mapStateToProps)(CardActivation);
\ No newline at end of file
export default connect(mapStateToProps, mapDispatchToProps)(CardActivation);
\ No newline at end of file
......@@ -11,7 +11,8 @@ class ChangeEmail extends React.Component {
constructor(props) {
super(props);
this.state = {
email: ""
email: "",
caretHidden:true
}
}
......@@ -63,7 +64,9 @@ class ChangeEmail extends React.Component {
value={this.state.email}
autoCapitalize="none"
value={this.state.email}
keyboardType='email-address' />
keyboardType='email-address'
caretHidden={this.state.caretHidden}
onFocus={() => this.setState({caretHidden: false})}/>
<TouchableOpacity style={{ height: 100 }} onPress={() => this.changeEmail()}>
<View style={{ backgroundColor: '#CFB368', height: 45, top: 20, borderRadius: 10, marginRight: 50, marginLeft: 50 }}>
<Text style={{ alignSelf: 'center', top: 10, color: 'white', fontFamily: 'Gotham-Black', fontSize: 20 }}>SUBMIT</Text>
......
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