import EditGrayA from "@/components/icons/EditGrayA"; import EditOrangeA from "@/components/icons/EditOrangeA"; import { Button, TextField } from "@mui/material"; // تابع تبدیل اعداد فارسی و عربی به انگلیسی const convertPersianToEnglish = (str) => { const persianNumbers = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']; const arabicNumbers = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩']; let result = str; for (let i = 0; i < 10; i++) { const regex = new RegExp(persianNumbers[i], 'g'); result = result.replace(regex, i.toString()); const arabicRegex = new RegExp(arabicNumbers[i], 'g'); result = result.replace(arabicRegex, i.toString()); } return result; }; function EditField({ changeData, multiline, icon, placeholder, data, name, iconGray, isTransparent, noDisable, type, props, error, }) { const handleChange = (e) => { let inputValue = e.target.value; // اگر فیلد کد ملی یا شماره موبایل یا شماره بیمه است، فقط اعداد انگلیسی if (name === "national_code" || name === "phone" || name === "insurance_id" || type === "tel") { // ابتدا اعداد فارسی و عربی را به انگلیسی تبدیل کن inputValue = convertPersianToEnglish(inputValue); // فقط اعداد انگلیسی را نگه دار inputValue = inputValue.replace(/[^0-9]/g, ''); // محدودیت تعداد ارقام if (name === "national_code" && inputValue.length > 10) { inputValue = inputValue.slice(0, 10); } else if (name === "phone" && inputValue.length > 11) { inputValue = inputValue.slice(0, 11); } else if (name === "insurance_id" && inputValue.length > 16) { inputValue = inputValue.slice(0, 16); } } changeData(inputValue, "value", name); }; return (