import * as React from 'react';
import {
TouchableOpacity,
Platform,
View,
Text,
Image,
Alert,
Modal
} from 'react-native';
import {
Container,
FormControl,
Stack,
Input
} from 'native-base';
import { connect } from "react-redux";
import CustomHeader from '../../components/header.js';
import Assets from '../../components/assets.manager.js';
import Theme from '../../components/theme.style.js';
import Elements from '../../components/elements.js';
import IconX from '../../components/icons.js';
import REQUEST from '../../components/api/';
import CustomSafeArea from '../../components/safeArea.component.js';
const styles = {
centeredView: {
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: '#00000090',
padding: 30
},
bottomView: {
flex: 1,
justifyContent: "flex-end",
alignItems: "center",
backgroundColor: '#00000090',
padding: 0
},
modalView: {
backgroundColor: '#fff',
padding: 20
},
modalTitle: {
padding: 5,
fontSize: 18,
fontWeight: 'bold'
},
modalText: {
padding: 5,
fontSize: 16,
color: 'gray',
marginTop: 10
}
}
class ApplyCardDetails extends React.Component {
constructor(props) {
super(props)
this.card = props.route.params || {}
}
state = {
loading: false,
modalvisible: false,
pin: null,
valid: false
}
componentDidMount() {
}
componentWillUnmount() {
}
proceed = () => {
this.props.navigation.navigate("EnrollForm", {
card_number: this.card.card_number,
pin: this.state.pin,
transactionType: this.props.route.params?.transactionType
})
}
onNext = async () => {
this.setState({ loading: true })
let body = {
card_number: this.card.card_number,
pin: this.state.pin
}
await REQUEST("send_card_pin", "post", {}, {}, body, (res) => {
this.setState({ loading: false })
if(res.status == 0){
Platform.OS == 'ios' ? setTimeout(() => {
Alert.alert("Error", res.message)
}, 300) : Alert.alert("Error", res.message)
} else {
this.proceed()
}
}, (error) => {
this.setState({ loading: false })
Platform.OS == 'ios' ? setTimeout(() => {
Alert.alert("Error", error.message)
}, 300) : Alert.alert("Error", error.message)
})
}
render() {
return (
Enter Your Pin
Please see the PIN at the back of your card
this.setState({ modalvisible: true })} />
PIN Code
this.setState({ pin: val, valid: val.length == 8 ? true : false })} />
this.onNext() } style={{backgroundColor: this.state.valid ? Theme.colors.primary : this.props.app_theme?.theme.dark ? this.props.app_theme?.theme.colors.border : Theme.colors.primary + 15, borderRadius: 5}}>
Submit
this.setState({ modalvisible: false })} style={{...styles.centeredView, borderRadius: 12}}>
);
}
}
const mapStateToProps = (state) => {
return {
app_theme: state.appThemeReducer.theme
}
}
export default connect(mapStateToProps, null)(ApplyCardDetails)
// export default function ApplyCardDetails(navigation) {
// const card = navigation.route.params || {}
// const [loading, setloading] = useState(false)
// const [modalvisible, setmodalvisible] = useState(false)
// const [pin, setpin] = useState(null)
// const [valid, setvalid] = useState(false)
// const init = async () => {
// console.log(card)
// }
// useEffect(() => {
// init()
// }, [])
// const Proceed = () => {
// navigation.navigation.navigate("EnrollForm", {
// card_number: card.card_number,
// pin: pin,
// transactionType: navigation.route.params?.transactionType
// })
// }
// const onNext = async () => {
// setloading(true)
// let body = {
// card_number: card.card_number,
// pin: pin
// }
// // alert(JSON.stringify(body))
// await REQUEST("send_card_pin", "post", {}, {}, body, function(res){
// console.log("RESULT", res)
// setloading(false)
// if(res.status == 0){
// Platform.OS == 'ios' ? setTimeout(() => {
// Alert.alert("Error", res.message)
// }, 300) : Alert.alert("Error", res.message)
// }else{
// Proceed()
// }
// }, function(error){
// console.log(error)
// setloading(false)
// })
// }
// return (
//
//
//
//
//
// Enter Your Pin
// Please see the PIN at the back of your card
// setmodalvisible(true)} />
//
//
//
// onNext() } style={{backgroundColor: Theme.colors.primary, borderRadius: 5}}>
// Next
//
//
// setmodalvisible(false)} style={{...styles.centeredView, borderRadius: 12}}>
//
//
//
//
//
//
//
// );
// }