import * as React from 'react'; import { useState, useEffect } from 'react'; import { connect } from "react-redux"; import { SafeAreaView, ScrollView, TouchableOpacity, Button, View, Text, Linking } from 'react-native'; import {useNetInfo} from "@react-native-community/netinfo"; // import NetInfo from "@react-native-community/netinfo"; import NetInfo from "../../components/netstatus"; 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 REQUEST from '../../components/api/'; import { ContactOptions, ContactOptionsWithParams } from '../../components/contact.action'; import DB from '../../components/storage/index'; import CustomSafeArea from '../../components/safeArea.component'; class LoginSendOTP extends React.PureComponent { constructor(props) { super(props) } state = { loading: false, data: {}, contact: {}, contactselect: false, mobile_number: null, openOptions: false } componentDidMount() { this.init() } componentWillUnmount() { } init = async () => { this.setState({ data: this.props.route.params.data, mobile_number: this.props.route.params.mobile_number }) console.log(this.props.route.params) } onSend = () => { NetInfo.netstatus(isConnected => { if(isConnected) { this.requestOTP(success => { this.setState({ loading: false }) console.log(success) if(success.status == 1) { this.props.navigation.navigate("AccountOtp", { data: this.state.data, callback: this.props.route.params?.callback, type: this.props.route.params?.type }) } }, error => { this.setState({ loading: false }) }) } else { Elements.nointernet2(this.props) } }) } requestOTP = async (successCallback, errorCallback) => { this.setState({ loading: true }) let params = `lcard_uuid=${this.state.data.lcard_uuid}&mobile=${Theme.formatter.PMBL(this.state.data.mobile_number)}&is_resend=false`; await REQUEST("requestOTP", "get", {}, params, {}, function(res){ successCallback(res) }, function(error){ errorCallback(error) }) } render() { return ( this.props.navigation.goBack()} navigation={this.props.navigation} /> Please Confirm We will send you a One Time Passcode to {Theme.formatter.ENCMBL(this.state.data.mobile_number || "+639000000000")} this.onSend()} style={{backgroundColor: Theme.colors.primary, padding: 15, width: '80%', borderRadius: 10, elevation: 3}}> Send me the code Not your mobile number? this.setState({ openOptions: true })} style={{flex: 2}}> Contact Us this.setState({ openOptions: false })} /> ); } } const mapStateToProps = (state) => { return { app_theme: state.appThemeReducer.theme } } export default connect(mapStateToProps, null)(LoginSendOTP)