From f660021782ad4b01eda58a5d223e86b4a0b0aae1 Mon Sep 17 00:00:00 2001 From: Vyacheslav Scherbinin Date: Wed, 28 Feb 2024 10:07:32 +0700 Subject: [PATCH 1/8] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B8=D1=80=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B8=20=D0=BD=D0=B5=D0=B8=D1=81=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=B7=D1=83=D0=B5=D0=BC=D1=8B=D0=B9=20=D0=BA=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 83 -------------------------------------------------------- 1 file changed, 83 deletions(-) diff --git a/index.js b/index.js index 0530ce9..0c3c79d 100644 --- a/index.js +++ b/index.js @@ -16,7 +16,6 @@ import { DateInput, SuggestionsInput, RadioButtons, - Checkbox, FormRow, Button, Spinner, @@ -36,19 +35,11 @@ export const ProfileInfo = (props) => { permissions, rejectSet, isJuridical, - sendForInspection, - isManager, - sendAgentCard, - // surnameSuggestions, - // firstNameSuggestions, - // patronymicSuggestions, phoneVerification, username, openModal, subscribe, setSubscribe, - // personInputs, - // paymentInfo, whatsApp, whatsAppSetNotifications, } = props; @@ -277,7 +268,6 @@ export const ProfileInfo = (props) => { }} /> { )} - {false && props.username === userInfo.username && ( - - - props.setCanPrecalculation(!props.canPrecalculation) - } - withoutLabel - big - > - Разрешить бронирование (доступно только для пользователей c - подтверждённым номером телефона) - - - )} - {false && isManager && !newUser && ( - - - setValue( - ["sendForInspection", "needToSend"], - !sendForInspection.needToSend - ) - } - > - Передать данные на ТО - - - setValue(["sendForInspection", "email"], e.target.value) - } - onBlur={(e) => { - validate("inspectionEmail", e.target.value); - }} - /> - - - )} - {/* Платёжная информация -

Карту необходимо указывать "Сбербанк".

-

- *если у Вас нет карты "Сбербанк" Вы можете указать карту лица, которому - доверяете. -

- */} {permissions.editSubscribe && ( )} From 29313ec52a8ef680eaef9e02c154f502632ee7a9 Mon Sep 17 00:00:00 2001 From: Vyacheslav Scherbinin Date: Wed, 28 Feb 2024 10:12:02 +0700 Subject: [PATCH 2/8] =?UTF-8?q?=D0=92=D1=8B=D0=BD=D0=B5=D1=81=20=D0=B3?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D1=8E=20=D0=BF=D0=B0?= =?UTF-8?q?=D1=80=D0=BE=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 13 +------------ utils.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 utils.js diff --git a/index.js b/index.js index 0c3c79d..fe37247 100644 --- a/index.js +++ b/index.js @@ -21,6 +21,7 @@ import { Spinner, Range, } from "../../UiComponents"; +import { generatePassword } from "./utils"; export const ProfileInfo = (props) => { const { @@ -58,18 +59,6 @@ export const ProfileInfo = (props) => { }); }; - const generatePassword = () => { - const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=!@#№$;%^:&?*()_+"; - const length = 10; - let result = ""; - - for (let i = 0; i < length; i++) { - result += charset.charAt(Math.floor(Math.random() * charset.length)); - } - - return result; - }; - if (loading) { return ( diff --git a/utils.js b/utils.js new file mode 100644 index 0000000..f836cef --- /dev/null +++ b/utils.js @@ -0,0 +1,11 @@ + +export const generatePassword = (length = 10) => { + const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=!@#№$;%^:&?*()_+"; + let result = ""; + + for (let i = 0; i < length; i++) { + result += charset.charAt(Math.floor(Math.random() * charset.length)); + } + + return result; +}; From 3c3cacfe4adc93572a06914c88d8f7a69d92899b Mon Sep 17 00:00:00 2001 From: Vyacheslav Scherbinin Date: Wed, 28 Feb 2024 10:13:33 +0700 Subject: [PATCH 3/8] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=B5=D1=81?= =?UTF-8?q?=20=D1=80=D0=B5=D0=BD=D0=B4=D0=B5=D1=80=20=D1=81=D0=BF=D0=B8?= =?UTF-8?q?=D0=BD=D0=B5=D1=80=D0=B0=20=D0=B1=D0=BB=D0=B8=D0=B6=D0=B5=20?= =?UTF-8?q?=D0=BA=20=D0=BE=D1=81=D0=BD=D0=BE=D0=B2=D0=BD=D0=BE=D0=BC=D1=83?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index fe37247..707d9e8 100644 --- a/index.js +++ b/index.js @@ -59,14 +59,6 @@ export const ProfileInfo = (props) => { }); }; - if (loading) { - return ( - - - - ); - } - const setIsJuridical = (value) => { if (permissions.editJuridical) { setValue(["userInfo", "isJuridical"], value); @@ -79,6 +71,12 @@ export const ProfileInfo = (props) => { showError(internalErrors, errorsServer); + if (loading) return ( + + + + ); + return ( <> From 94a951e4da755168b2578a608c27318736ade995 Mon Sep 17 00:00:00 2001 From: Vyacheslav Scherbinin Date: Wed, 28 Feb 2024 10:17:25 +0700 Subject: [PATCH 4/8] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=B5=D1=81?= =?UTF-8?q?=20=D0=B2=20useEffect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 707d9e8..4f90956 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ * Компонент отображения формы ввода личных данных в создании/редактировании агента * from: ProfileInfo */ +import { React, useEffect } from "react"; import PropTypes from "prop-types"; import moment from "moment"; @@ -45,7 +46,7 @@ export const ProfileInfo = (props) => { whatsAppSetNotifications, } = props; - const showError = (internalErrors, errorsServer) => { + useEffect(() => { if (!errorsServer && !errorsServer.isArray()) return null; errorsServer.forEach((elem) => { @@ -57,7 +58,7 @@ export const ProfileInfo = (props) => { internalErrors.email = elem.message; } }); - }; + }, [internalErrors, errorsServer]); const setIsJuridical = (value) => { if (permissions.editJuridical) { @@ -69,8 +70,6 @@ export const ProfileInfo = (props) => { } }; - showError(internalErrors, errorsServer); - if (loading) return ( From 958b70dfe7128eca311df467392e0f003a6ecc44 Mon Sep 17 00:00:00 2001 From: Vyacheslav Scherbinin Date: Wed, 28 Feb 2024 11:08:44 +0700 Subject: [PATCH 5/8] =?UTF-8?q?=D0=92=D1=8B=D0=BD=D0=B5=D1=81=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D1=81=D1=82=D0=B0=D0=BD=D1=82=D1=8B,=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=D1=87=D0=B5=D1=81=D0=B0=D0=BB=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=BF=D1=81=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- const.js | 73 +++++++++++++++++++ index.js | 219 +++++++++++++++++++++++++++---------------------------- utils.js | 3 +- 3 files changed, 184 insertions(+), 111 deletions(-) create mode 100644 const.js diff --git a/const.js b/const.js new file mode 100644 index 0000000..d97340a --- /dev/null +++ b/const.js @@ -0,0 +1,73 @@ +export const MAGIC_STRINGS = { + userInfo:"userInfo", + username:"username", + series:"series", + password:"password", + isJuridical:"isJuridical", + firstname:"firstname", + surname:"surname", + patronymic:"patronymic", + emailCanonical:"emailCanonical", + passport:"passport", + email:"email", + inn:"inn", + snils:"snils", + whatsAppAuthModal:"whatsAppAuthModal", + redirect_url:"redirect_url", + address:"address", + addressInProfile:"addressInProfile", + description:"description", + number:"number", + birthday:"birthday", + issuedAt:"issuedAt", + phone:"phone", + usernameCanonical:"usernameCanonical", + workHours:"workHours", + verificationPhoneModal: "verificationPhoneModal", + success: "success", + error: "error", + text: "text", +}; +export const LOCALES = { + address: "Адрес", + addressDefault: "Регион, город, улица", + login: "Логин", + password: "Пароль", + generate: "сгенерировать", + surname: "Фамилия", + surnameDefault: "Иванов", + name: "Имя", + nameDefault: "Иван", + patronymic: "Отчество", + patronymicDefault: "Иванович", + physical: "Физическое лицо", + juridical: "Юридическое лицо", + inn: "ИНН", + passportSerial: "Серия паспорта", + passportSerialDefault: "9999", + passportNumber: "Номер паспорта", + passportNumberDefault: "123456", + birthday: "Дата рождения", + snils: "СНИЛС", + email: "Электронная почта", + phone: "Телефон", + remark: "Примечание", + workHours: "Рабочие часы", + phoneConfirmed: "Ваш номер подтверждён", + phoneNotConfirmed: "Ваш номер не подтверждён", + whatsappBotEnable: "Подключить бота Whatsapp", + whatsappNotifyDisable: "Отключить уведомления Whatsapp", + whatsappNotifyEnable: "Подключить уведомления Whatsapp", + juridicalError: "Если вы хотите работать как юридическое лицо, то необходимо заключить с нами договор. Для этого вам нужно обратиться в тех. поддержку по телефону +7 (800) 550-50-43, либо написать на почту docs@rosstrah.ru, в теме письма указав свой логин", +}; +export const DATES_FORMAT = { + DDMMYYYY:"DD.MM.YYYY", +} +export const PASSWORD_CHARSET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=!@#№$;%^:&?*()_+"; +export const REGEXP = { + inn: /^[\d]{0,12}$/, + passportSerial: /^[\d]{0,4}$/, + passportNumber: /^[\d]{0,6}$/, + birthday: /^[.\d]{0,10}$/, + snils: /^[\d]{0,11}$/, +}; diff --git a/index.js b/index.js index 4f90956..6481119 100644 --- a/index.js +++ b/index.js @@ -23,6 +23,7 @@ import { Range, } from "../../UiComponents"; import { generatePassword } from "./utils"; +import { MAGIC_STRINGS, LOCALES, REGEXP, DATES_FORMAT } from "./const"; export const ProfileInfo = (props) => { const { @@ -51,10 +52,10 @@ export const ProfileInfo = (props) => { errorsServer.forEach((elem) => { internalErrors[elem.key] = elem.message; - if (elem.key === "usernameCanonical") { + if (elem.key === MAGIC_STRINGS.usernameCanonical) { internalErrors.username = elem.message; } - if (elem.key === "emailCanonical") { + if (elem.key === MAGIC_STRINGS.emailCanonical) { internalErrors.email = elem.message; } }); @@ -62,11 +63,9 @@ export const ProfileInfo = (props) => { const setIsJuridical = (value) => { if (permissions.editJuridical) { - setValue(["userInfo", "isJuridical"], value); + setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.isJuridical], value); } else { - rejectSet(`Если вы хотите работать как юридическое лицо, то необходимо заключить с нами договор. Для этого вам нужно обратиться в тех. поддержку по телефону - +7 (800) 550-50-43, - либо написать на почту docs@rosstrah.ru, в теме письма указав свой логин`); + rejectSet(LOCALES.juridicalError); } }; @@ -80,44 +79,44 @@ export const ProfileInfo = (props) => { <> setValue(["userInfo", "username"], value)} + onChange={(value) => setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.username], value)} onBlur={(value) => { - validate("username", value); + validate(MAGIC_STRINGS.username, value); }} error={ internalErrors.username || errorsServer.find((el) => - ["username", "usernameCanonical"].includes(el.key) + [MAGIC_STRINGS.username, MAGIC_STRINGS.usernameCanonical].includes(el.key) ) } /> {permissions.editPassword && ( el.key === "password") - } - label="Пароль" + id={MAGIC_STRINGS.password} + label={LOCALES.password} value={userInfo.password} autoComplete="off" - onChange={(value) => setValue(["userInfo", "password"], value)} + onChange={(value) => setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.password], value)} onBlur={(value) => { - if (newUser) validate("password", value); + if (newUser) validate(MAGIC_STRINGS.password, value); }} + error={ + internalErrors.password || + errorsServer.find((el) => el.key === MAGIC_STRINGS.password) + } after={ ) : ( ))} { - validate("addressInProfile", address); - removeError("addressInProfile"); + validate(MAGIC_STRINGS.addressInProfile, address); + removeError(MAGIC_STRINGS.addressInProfile); }} - onChange={setValue} error={internalErrors.addressInProfile} /> {permissions.editNote && ( setValue(["userInfo", "notes"], value)} + onChange={(value) => setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.notes], value)} /> )} {username === userInfo.username && userInfo.workHours && ( <> - Рабочие часы + {LOCALES.workHours} setValue(["userInfo", "workHours"], value)} + onChange={(value) => setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.workHours], value)} /> diff --git a/utils.js b/utils.js index f836cef..5115104 100644 --- a/utils.js +++ b/utils.js @@ -1,6 +1,7 @@ +import { PASSWORD_CHARSET } from "./const"; export const generatePassword = (length = 10) => { - const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=!@#№$;%^:&?*()_+"; + const charset = PASSWORD_CHARSET; let result = ""; for (let i = 0; i < length; i++) { From cd90bf59c287fab11e129b294de4de4bbb7fb186 Mon Sep 17 00:00:00 2001 From: Vyacheslav Scherbinin Date: Wed, 28 Feb 2024 13:44:43 +0700 Subject: [PATCH 6/8] =?UTF-8?q?=D0=94=D0=B5=D1=81=D1=82=D1=80=D1=83=D0=BA?= =?UTF-8?q?=D1=82=D1=83=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=81=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D0=BB=D1=8F=D1=8E?= =?UTF-8?q?=D1=89=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ContactInfoForm.js | 143 +++++++++++++ components/LegalInfoForm.js | 145 +++++++++++++ components/PersonalInfoForm.js | 105 ++++++++++ index.js | 362 +++------------------------------ 4 files changed, 424 insertions(+), 331 deletions(-) create mode 100644 components/ContactInfoForm.js create mode 100644 components/LegalInfoForm.js create mode 100644 components/PersonalInfoForm.js diff --git a/components/ContactInfoForm.js b/components/ContactInfoForm.js new file mode 100644 index 0000000..bf8e0d6 --- /dev/null +++ b/components/ContactInfoForm.js @@ -0,0 +1,143 @@ +import localStorage from '../../../utils/browser/localStorage'; +import { WarningIcon, SuccessIcon } from '../../../Icons'; +import { Input, SuggestionsInput, FormRow, Button, Range } from '../../../UiComponents'; +import { MAGIC_STRINGS, LOCALES } from "./const"; + +export const ContactInfoForm = (props) => { + const { + userInfo, + setValue, + validate, + internalErrors, + removeError, + permissions, + phoneVerification, + username, + openModal, + whatsApp, + whatsAppSetNotifications, + } = props; + + const sameUser = username === userInfo.username; + const whatsAppEnabled = sameUser && whatsApp && whatsApp.bot_enabled; + const userWorkHours = sameUser && userInfo.workHours; + + const phoneVerificationButton = sameUser && ( + + ); + + const whatsAppNotifyButton = ( + + ); + const whatsAppBotButton = ( + + ); + + return ( + <> + + setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.email], value)} + onBlur={(value) => { + validate(MAGIC_STRINGS.email, value); + }} + error={internalErrors.email} + /> + setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.phone], value)} + onBlur={(value) => { + validate(MAGIC_STRINGS.phone, value); + }} + error={internalErrors.phone} + after={phoneVerificationButton} + /> + { + whatsAppEnabled + && (whatsApp.bot_started ? whatsAppNotifyButton : whatsAppBotButton) + } + { + validate(MAGIC_STRINGS.addressInProfile, address); + removeError(MAGIC_STRINGS.addressInProfile); + }} + error={internalErrors.addressInProfile} + /> + + {permissions.editNote && ( + + setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.notes], value)} + /> + + )} + {userWorkHours && ( + <> + {LOCALES.workHours} + + setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.workHours], value)} + /> + + + )} + + ); +}; + +export default ContactInfoForm; diff --git a/components/LegalInfoForm.js b/components/LegalInfoForm.js new file mode 100644 index 0000000..f31c386 --- /dev/null +++ b/components/LegalInfoForm.js @@ -0,0 +1,145 @@ +import moment from "moment"; + +import { + Input, + DateInput, + RadioButtons, + FormRow, +} from "../../../UiComponents"; +import { MAGIC_STRINGS, LOCALES, REGEXP, DATES_FORMAT } from "./const"; + +export const LegalInfoForm = (props) => { + const { + userInfo, + setValue, + validate, + internalErrors, + isJuridical, + permissions, + rejectSet, + } = props; + + const setIsJuridical = (value) => { + if (permissions.editJuridical) { + setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.isJuridical], value); + } else { + rejectSet(LOCALES.juridicalError); + } + }; + + return ( + + setIsJuridical(value)} + /> + {isJuridical ? ( + { + if ( + REGEXP.inn.test(value) || + value.length < userInfo.inn.length + ) + return setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.inn], value); + }} + /> + ) : ( + <> + { + if ( + REGEXP.passportSerial.test(value) || + value.length < userInfo.series.length + ) + return setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.series], value); + }} + onBlur={(value) => { + validate(MAGIC_STRINGS.series, value, { + documentType: MAGIC_STRINGS.passport, + }); + }} + error={internalErrors.series} + /> + { + if ( + REGEXP.passportNumber.test(value) || + value.length < userInfo.number.length + ) + return setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.number], value); + }} + onBlur={(value) => { + validate(MAGIC_STRINGS.number, value, { + documentType: MAGIC_STRINGS.passport, + }); + }} + error={internalErrors.number} + /> + { + if ( + REGEXP.birthday.test(value) || + value.length < userInfo.birthday.length + ) + return setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.birthday], value); + }} + onBlur={(value) => { + validate(MAGIC_STRINGS.birthday, value); + if (userInfo.issuedAt) + validate(MAGIC_STRINGS.issuedAt, userInfo.issuedAt, { + documentType: MAGIC_STRINGS.passport, + birth: value, + }); + if (moment(value, DATES_FORMAT.DDMMYYYY).isValid()) { + setValue( + [MAGIC_STRINGS.userInfo, MAGIC_STRINGS.birthday], + moment(value, DATES_FORMAT.DDMMYYYY).format(DATES_FORMAT.DDMMYYYY) + ); + } + }} + error={internalErrors.birthday} + /> + { + if ( + REGEXP.snils.test(value) || + value.length < userInfo.snils.length + ) + return setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.snils], value); + }} + /> + + )} + + ); +}; + +export default LegalInfoForm; \ No newline at end of file diff --git a/components/PersonalInfoForm.js b/components/PersonalInfoForm.js new file mode 100644 index 0000000..af386b7 --- /dev/null +++ b/components/PersonalInfoForm.js @@ -0,0 +1,105 @@ +import { DicesIcon } from "../../../Icons"; +import { + Input, + FormRow, + Button, +} from "../../../UiComponents"; +import { generatePassword } from "../utils"; +import { MAGIC_STRINGS, LOCALES } from "./const"; + +export const PersonalInfoForm = (props) => { + const { + userInfo, + newUser, + setValue, + validate, + internalErrors, + errorsServer, + permissions, + } = props; + + return ( + + setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.username], value)} + onBlur={(value) => { + validate(MAGIC_STRINGS.username, value); + }} + error={ + internalErrors.username || + errorsServer.find((el) => + [MAGIC_STRINGS.username, MAGIC_STRINGS.usernameCanonical].includes(el.key) + ) + } + /> + + {permissions.editPassword && ( + setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.password], value)} + onBlur={(value) => { + if (newUser) validate(MAGIC_STRINGS.password, value); + }} + error={ + internalErrors.password || + errorsServer.find((el) => el.key === MAGIC_STRINGS.password) + } + after={ + + } + /> + )} + setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.surname], value)} + onBlur={(value) => { + validate(MAGIC_STRINGS.surname, value); + }} + error={internalErrors.surname} + /> + setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.firstname], value)} + onBlur={(value) => { + validate(MAGIC_STRINGS.firstname, value); + }} + error={internalErrors.firstname} + /> + setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.patronymic], value)} + /> + + ); +}; + +export default PersonalInfoForm; \ No newline at end of file diff --git a/index.js b/index.js index 6481119..5bc2978 100644 --- a/index.js +++ b/index.js @@ -4,26 +4,14 @@ */ import { React, useEffect } from "react"; import PropTypes from "prop-types"; -import moment from "moment"; import withValidate from "../../utils/injectValidate"; -import localStor from "../../utils/browser/localStorage"; import { validateInput } from "../../utils/validate"; import { EmptyNoBorder } from "../../CommonStyled"; import Subscribe from "../Subscribe"; -import { DicesIcon, WarningIcon, SuccessIcon } from "../../Icons"; import { - Input, - DateInput, - SuggestionsInput, - RadioButtons, - FormRow, - Button, Spinner, - Range, } from "../../UiComponents"; -import { generatePassword } from "./utils"; -import { MAGIC_STRINGS, LOCALES, REGEXP, DATES_FORMAT } from "./const"; export const ProfileInfo = (props) => { const { @@ -61,14 +49,6 @@ export const ProfileInfo = (props) => { }); }, [internalErrors, errorsServer]); - const setIsJuridical = (value) => { - if (permissions.editJuridical) { - setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.isJuridical], value); - } else { - rejectSet(LOCALES.juridicalError); - } - }; - if (loading) return ( @@ -77,317 +57,37 @@ export const ProfileInfo = (props) => { return ( <> - - setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.username], value)} - onBlur={(value) => { - validate(MAGIC_STRINGS.username, value); - }} - error={ - internalErrors.username || - errorsServer.find((el) => - [MAGIC_STRINGS.username, MAGIC_STRINGS.usernameCanonical].includes(el.key) - ) - } - /> - - {permissions.editPassword && ( - setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.password], value)} - onBlur={(value) => { - if (newUser) validate(MAGIC_STRINGS.password, value); - }} - error={ - internalErrors.password || - errorsServer.find((el) => el.key === MAGIC_STRINGS.password) - } - after={ - - } - /> - )} - setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.surname], value)} - onBlur={(value) => { - validate(MAGIC_STRINGS.surname, value); - }} - error={internalErrors.surname} - /> - setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.firstname], value)} - onBlur={(value) => { - validate(MAGIC_STRINGS.firstname, value); - }} - error={internalErrors.firstname} - /> - setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.patronymic], value)} - /> - - - setIsJuridical(value)} - /> - {isJuridical ? ( - { - if ( - REGEXP.inn.test(value) || - value.length < userInfo.inn.length - ) - return setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.inn], value); - }} - /> - ) : ( - <> - { - if ( - REGEXP.passportSerial.test(value) || - value.length < userInfo.series.length - ) - return setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.series], value); - }} - onBlur={(value) => { - validate(MAGIC_STRINGS.series, value, { - documentType: MAGIC_STRINGS.passport, - }); - }} - error={internalErrors.series} - /> - { - if ( - REGEXP.passportNumber.test(value) || - value.length < userInfo.number.length - ) - return setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.number], value); - }} - onBlur={(value) => { - validate(MAGIC_STRINGS.number, value, { - documentType: MAGIC_STRINGS.passport, - }); - }} - error={internalErrors.number} - /> - { - if ( - REGEXP.birthday.test(value) || - value.length < userInfo.birthday.length - ) - return setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.birthday], value); - }} - onBlur={(value) => { - validate(MAGIC_STRINGS.birthday, value); - if (userInfo.issuedAt) - validate(MAGIC_STRINGS.issuedAt, userInfo.issuedAt, { - documentType: MAGIC_STRINGS.passport, - birth: value, - }); - if (moment(value, DATES_FORMAT.DDMMYYYY).isValid()) { - setValue( - [MAGIC_STRINGS.userInfo, MAGIC_STRINGS.birthday], - moment(value, DATES_FORMAT.DDMMYYYY).format(DATES_FORMAT.DDMMYYYY) - ); - } - }} - error={internalErrors.birthday} - /> - { - if ( - REGEXP.snils.test(value) || - value.length < userInfo.snils.length - ) - return setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.snils], value); - }} - /> - - )} - - - setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.email], value)} - onBlur={(value) => { - validate(MAGIC_STRINGS.email, value); - }} - error={internalErrors.email} - /> - setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.phone], value)} - onBlur={(value) => { - validate(MAGIC_STRINGS.phone, value); - }} - error={internalErrors.phone} - after={ - username === userInfo.username && ( - - ) - } - /> - {username === userInfo.username && - whatsApp && - whatsApp.bot_enabled && - (whatsApp.bot_started ? ( - - ) : ( - - ))} - { - validate(MAGIC_STRINGS.addressInProfile, address); - removeError(MAGIC_STRINGS.addressInProfile); - }} - error={internalErrors.addressInProfile} - /> - - {permissions.editNote && ( - - setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.notes], value)} - /> - - )} - {username === userInfo.username && userInfo.workHours && ( - <> - {LOCALES.workHours} - - setValue([MAGIC_STRINGS.userInfo, MAGIC_STRINGS.workHours], value)} - /> - - - )} + + + {permissions.editSubscribe && ( )} From a5bb0675eceb90fd862007b9d02a2aad45716d76 Mon Sep 17 00:00:00 2001 From: Vyacheslav Scherbinin Date: Wed, 28 Feb 2024 14:11:02 +0700 Subject: [PATCH 7/8] =?UTF-8?q?=D0=9C=D0=B5=D0=BC=D0=BE=D0=B8=D0=B7=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BB=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ContactInfoForm.js | 4 +++- components/LegalInfoForm.js | 3 ++- components/PersonalInfoForm.js | 4 +++- index.js | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/components/ContactInfoForm.js b/components/ContactInfoForm.js index bf8e0d6..424337e 100644 --- a/components/ContactInfoForm.js +++ b/components/ContactInfoForm.js @@ -1,3 +1,5 @@ +import React, { memo } from "react"; + import localStorage from '../../../utils/browser/localStorage'; import { WarningIcon, SuccessIcon } from '../../../Icons'; import { Input, SuggestionsInput, FormRow, Button, Range } from '../../../UiComponents'; @@ -140,4 +142,4 @@ export const ContactInfoForm = (props) => { ); }; -export default ContactInfoForm; +export default memo(ContactInfoForm); diff --git a/components/LegalInfoForm.js b/components/LegalInfoForm.js index f31c386..42ab7f9 100644 --- a/components/LegalInfoForm.js +++ b/components/LegalInfoForm.js @@ -1,3 +1,4 @@ +import React, { memo } from "react"; import moment from "moment"; import { @@ -142,4 +143,4 @@ export const LegalInfoForm = (props) => { ); }; -export default LegalInfoForm; \ No newline at end of file +export default memo(LegalInfoForm); \ No newline at end of file diff --git a/components/PersonalInfoForm.js b/components/PersonalInfoForm.js index af386b7..fb64f89 100644 --- a/components/PersonalInfoForm.js +++ b/components/PersonalInfoForm.js @@ -1,3 +1,5 @@ +import React, { memo } from "react"; + import { DicesIcon } from "../../../Icons"; import { Input, @@ -102,4 +104,4 @@ export const PersonalInfoForm = (props) => { ); }; -export default PersonalInfoForm; \ No newline at end of file +export default memo(PersonalInfoForm); \ No newline at end of file diff --git a/index.js b/index.js index 5bc2978..feec4fb 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ * Компонент отображения формы ввода личных данных в создании/редактировании агента * from: ProfileInfo */ -import { React, useEffect } from "react"; +import React, { useEffect } from "react"; import PropTypes from "prop-types"; import withValidate from "../../utils/injectValidate"; From b036eacbd1bc8221ddbe934ee4318a456bd5c6d5 Mon Sep 17 00:00:00 2001 From: Vyacheslav Scherbinin Date: Wed, 28 Feb 2024 15:04:57 +0700 Subject: [PATCH 8/8] =?UTF-8?q?=D0=97=D0=B0=D0=BC=D0=B5=D1=87=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D1=80=D0=BE=20propTypes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index feec4fb..07f55e2 100644 --- a/index.js +++ b/index.js @@ -99,6 +99,7 @@ ProfileInfo.propTypes = { errorsServer: PropTypes.array, userInfo: PropTypes.object.isRequired, setValue: PropTypes.func.isRequired, + // Добавить остальные props }; export default withValidate(validateInput)(ProfileInfo);