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