import React, { useState } from "react"; import { connect } from "react-redux"; import { View, Text, ActivityIndicator, Dimensions, TouchableHighlight, Platform, KeyboardAvoidingView, ScrollView, } from "react-native"; import Svg, { Defs, Pattern, Image, Path } from "react-native-svg"; import onInput from "../../utils/onInput"; import { asyncAwesomeAlert } from "../../utils/AsyncWrappers"; import { user } from "../../redux/actions"; import { useNavigation } from "@react-navigation/native"; //components import CustomTextInput from "../../components/CustomTextInput"; //style import Colors from "../../constants/Colors"; import fontSize from "../../constants/fontSize"; import tw from "tailwind-rn"; const ios = Platform.OS === "ios"; const { height } = Dimensions.get("window"); function Login(props) { const navigation = useNavigation(); const [phone, setPhone] = useState(""); const [loading, setLoading] = useState(false); const onChangePhone = (name, value) => { setPhone(() => value); }; const checkPhoneNumber = () => { return phone.split("").length === 11 && phone.slice(0, 2) === "09"; }; const submit = async () => { setLoading(true); if (!checkPhoneNumber()) { setLoading(false); return asyncAwesomeAlert("خطا", "شماره وارد شده اشتباه است", { showCancelButton: false, }); } props.sendPhoneNumber({ cellphone: phone }); props.navigation.navigate("Otp", { phone: phone }); setLoading(false); }; return ( {"سلام"} {"خوش برگشتی!"} onInput.phonenumber(text)} /> {!props.mobile ? : null} submit()} > {loading ? ( ) : ( {"تایید شماره"} )} ورود شما در سامانه به منزله قبول و{" "} navigation.push("Rules")} > شرایط , قوانین استفاده {" "} می‌باشد ); } const mapStateToProps = (state) => ({ mobile: state.publicApi.mobile, theme: state.publicApi.theme, }); const mapDispatchToProps = { sendPhoneNumber: user.otp, }; export default connect(mapStateToProps, mapDispatchToProps)(Login);