refactor: enhance phone number validation and input handling in Field and LogInPage components
This commit is contained in:
@@ -4,6 +4,7 @@ import { request } from "@/services/response";
|
||||
import { InputAdornment, Button } from "@mui/material";
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
function LogInPage({ setIsSendMsg, num, setNum, setUuid, matchedCity, setStep }) {
|
||||
const [error, setError] = useState({ valid: true, text: "" });
|
||||
@@ -11,6 +12,12 @@ function LogInPage({ setIsSendMsg, num, setNum, setUuid, matchedCity, setStep })
|
||||
|
||||
const handleChange = (val) => {
|
||||
const checkedNum = validatePhoneNumber(val);
|
||||
|
||||
// اگر کاراکتر غیر عددی بود، notification نشون بده
|
||||
if (!checkedNum.valid && checkedNum.text === "فقط از اعداد انگلیسی استفاده کنید.") {
|
||||
toast.error("فقط از اعداد انگلیسی استفاده کنید.");
|
||||
}
|
||||
|
||||
setError(checkedNum);
|
||||
setNum(val);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user