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) => {