Merge branch 'bugfix/yasi_fixed_login_phone' into 'develop'

This commit is contained in:
AmirHossein Mahmoodi
2023-12-20 11:26:16 +00:00
2 changed files with 21 additions and 3 deletions

View File

@@ -99,7 +99,8 @@
"button_make_account": "ایجاد حساب", "button_make_account": "ایجاد حساب",
"button_request_verification": "دریافت کد یکبارمصرف", "button_request_verification": "دریافت کد یکبارمصرف",
"sent_token_to": "ارسال کد یکبار مصرف به شماره", "sent_token_to": "ارسال کد یکبار مصرف به شماره",
"change_phone_number": "تغییر شماره" "change_phone_number": "تغییر شماره",
"phone_number_max": "شماره تلفن می بایست 11 رقم باشد"
}, },
"RegisterPage": { "RegisterPage": {
"link_routing_back_to": "بازگشت به", "link_routing_back_to": "بازگشت به",

View File

@@ -27,7 +27,12 @@ const SendUserDataComponent = ({
phone_number: PhoneNumber, phone_number: PhoneNumber,
}; };
const validationSchema = Yup.object().shape({ const validationSchema = Yup.object().shape({
phone_number: Yup.string().required(t("LoginPage.error_message_phone_number")), phone_number: Yup.mixed()
.test("max", `${t("LoginPage.phone_number_max")}`, (value) => {
const stringValue = String(value);
return stringValue.length === 11
})
.required(t("LoginPage.error_message_phone_number")),
}); });
const handleSubmit = (values, props) => { const handleSubmit = (values, props) => {
@@ -76,7 +81,19 @@ const SendUserDataComponent = ({
placeholder={t( placeholder={t(
"LoginPage.text_field_enter_your_phone_number" "LoginPage.text_field_enter_your_phone_number"
)} )}
type={"text"} type={"tel"}
onChange={(event) => {
const inputValue = event.target.value;
if (isNaN(Number(inputValue))) {
return;
}
props.handleChange({
target: {
name: "phone_number",
value: inputValue,
},
});
}}
error={ error={
!!(props.touched.phone_number && props.errors.phone_number) !!(props.touched.phone_number && props.errors.phone_number)
} }