From b495974dba396fb4aedcd73c2b4e4305d021119a Mon Sep 17 00:00:00 2001 From: Nastya Date: Sat, 26 Jul 2025 01:38:35 +0300 Subject: [PATCH] =?UTF-8?q?fix=20lang=20=D0=B8=20=D0=BD=D0=BE=D0=BC=D0=B5?= =?UTF-8?q?=D1=80=20=D1=82=D0=B5=D0=BB=D0=B5=D1=84=D0=BE=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D0=B4=D0=B0=D1=81=D1=82=20=D0=BE=D1=82=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20=D0=B4=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=A4=D0=9A=20=D0=B5=D1=81=D0=BB=D0=B8=20=D0=BA?= =?UTF-8?q?=D0=BE=D1=80=D0=BE=D1=87=D0=B5=20=D0=BF=D0=BE=D0=BB=D0=BE=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D0=BE=D0=B3=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deployments/main/docker-compose.yaml | 2 +- .../ContactForm/ContactForm.tsx | 19 +++++++++++++++---- package.json | 2 +- src/i18n/i18nWidget.ts | 3 --- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/deployments/main/docker-compose.yaml b/deployments/main/docker-compose.yaml index 3fa7a99..d7a0ed4 100644 --- a/deployments/main/docker-compose.yaml +++ b/deployments/main/docker-compose.yaml @@ -2,6 +2,6 @@ services: respondent: container_name: respondent restart: unless-stopped - image: gitea.pena/squiz/frontanswerer/main:latest + image: gitea.pena/squiz/frontanswerer/main:202507260140 hostname: respondent tty: true diff --git a/lib/components/ViewPublicationPage/ContactForm/ContactForm.tsx b/lib/components/ViewPublicationPage/ContactForm/ContactForm.tsx index 2034425..d74acd4 100644 --- a/lib/components/ViewPublicationPage/ContactForm/ContactForm.tsx +++ b/lib/components/ViewPublicationPage/ContactForm/ContactForm.tsx @@ -179,15 +179,26 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => { // Функция валидации телефона const validatePhone = (phoneValue: string) => { - // Если номер не пустой и не полный (меньше 10 символов) - это ошибка - if (phoneValue.length > 0 && phoneValue.length < 10) { + // Убираем все нецифровые символы и считаем только цифры + const digitsOnly = phoneValue.replace(/\D/g, ""); + + // Для российских номеров (начинающихся с +7) нужно 11 цифр + // Для остальных стран - минимум 10 цифр + const isRussianNumber = phoneValue.startsWith("+7"); + const minDigits = isRussianNumber ? 11 : 10; + + // Если есть какие-то символы в инпуте, но цифр меньше минимума - это ошибка + if (phoneValue.trim().length > 0 && digitsOnly.length < minDigits) { return t("Please complete the phone number"); } return ""; }; // Проверяем валидность телефона при каждом изменении - const isPhoneValid = phone.length === 0 || phone.length >= 10; + const digitsOnly = phone.replace(/\D/g, ""); + const isRussianNumber = phone.startsWith("+7"); + const minDigits = isRussianNumber ? 11 : 10; + const isPhoneValid = phone.trim().length === 0 || digitsOnly.length >= minDigits; // Обработчик изменения телефона const handlePhoneChange = (newPhone: string) => { @@ -321,7 +332,7 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => {