import React, { Component } from "react"; import Timer from "../Timer/index"; import logo from "../../../../assets/icons/logo.png"; import "./index.scss"; const maxDesktopSize = 1250; const maxMobileSize = 550; const fontSize = { desktop: { input: window.innerWidth > maxDesktopSize ? 20 : window.innerWidth / 85, button: window.innerWidth > maxDesktopSize ? 16 : window.innerWidth / 85, div: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 95, }, mobile: { h1: window.innerWidth > maxMobileSize ? 24 : window.innerWidth / 13, p: window.innerWidth > maxMobileSize ? 13 : window.innerWidth / 27, input: window.innerWidth > maxMobileSize ? 20 : window.innerWidth / 85, button: window.innerWidth > maxMobileSize ? 16 : window.innerWidth / 85, div: window.innerWidth > maxMobileSize ? 12 : window.innerWidth / 30, }, }; export default class Code extends Component { constructor(props) { super(props); this.state = { resendStatus: false, }; } componentDidMount() { this.inputRef1.focus(); } onInput = (e) => { e.target.value = e.target.value .replace(/[\u0660-\u0669\u06f0-\u06f9]/g, function (c) { return c.charCodeAt(0) & 0xf; }) .replace(/[^\d]/, "") .slice(-1); }; changeValue = (e) => { if (e.target.value.match("^[0-9]{1}$")) { if (e.target.name === "o1") { this.setState({ o1: e.target.value }); this.inputRef2.focus(); } else if (e.target.name === "o2") { this.setState({ o2: e.target.value }); this.inputRef3.focus(); } else if (e.target.name === "o3") { this.setState({ o3: e.target.value }); this.inputRef4.focus(); } else if (e.target.name === "o4") { this.setState({ o4: e.target.value }); const o4 = e.target.value; const { o1, o2, o3 } = this.state; this.props.parent.setState({ otp: `${o1}${o2}${o3}${o4}` }); return; } } else { return; } }; keyboardEvent = (e) => { if (e.keyCode === 8) { this.setState({ [e.target.name]: "", }); if (e.target.name === "o1") { return; } else if (e.target.name === "o2") { this.inputRef1.focus(); return; } else if (e.target.name === "o3") { this.inputRef2.focus(); return; } else if (e.target.name === "o4") { this.inputRef3.focus(); return; } } }; render() { return ( <> {window.innerWidth > 1000 ? (
یک کد تائیدیه به شماره{" "}
{this.props.parent.state.cellphone} ارسال شد
آن را در قسمت زیر وارد کنید.