"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7729],{7729:function(e,t,s){s.d(t,{Z:function(){return SignInDialog}});var a=s(85893),n=s(67294),l=s(83321),i=s(64666),r=s(15861),o=s(82175),d=s(33299),c=s(82158),m=s(26303),x=s(33841),u=s(94054),h=s(57709),g=s(93946),N=s(87109),b=s(22961),p=s(72450),E=s(14705),j=s(44080),v=s(4813),w=s(37645),f=s(50594),A=s(65594);let T={[j.D1.NOT_FOUND]:"Пользователь с таким Email адресом не найден"};var dialogs_ForgotPasswordDialog=e=>{let{isOpen:t,onClose:s}=e,{isMobileBreakpoint:l}=(0,A.Z)(),[d,N]=(0,n.useState)(null),[b,p]=(0,n.useState)(!1),j=(0,n.useRef)(null),{mutate:I,isLoading:D}=c.h.users.forgotPassword.useMutation({onSuccess(){p(!0)},onError(e){var t;console.log(e.message),N(null!==(t=T[e.message])&&void 0!==t?t:"Что-то пошло не так!")}});return(0,a.jsxs)(i.Z,{open:t,onClose:s,fullScreen:l,maxWidth:!1,PaperProps:{sx:{padding:l?2:5,width:l?"100vw":"364px"}},children:[l?(0,a.jsxs)("div",{className:"relative flex items-center bg-red h-15 px-3 child:text-white -mx-4 mb-6",children:[(0,a.jsx)(g.Z,{onClick:s,className:"absolute w-5 h-5",children:(0,a.jsx)(f.Z,{})}),(0,a.jsx)(r.Z,{variant:"h3",className:"flex-1 text-center",children:"Восстановление пароля"})]}):(0,a.jsxs)(w.Z,{id:"forgot-password-dialog-title",variant:"h4",className:"mb-6 p-0",children:[(0,a.jsx)(g.Z,{onClick:s,className:"w-8 h-8 absolute top-6 right-6",children:(0,a.jsx)(f.Z,{})}),"Восстановление пароля"]}),b?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Z,{variant:"subtitle1",children:"В течении 1 минуты вам придёт письмо на почту. Переходите по ссылке, указанной в письме."}),(0,a.jsx)(v.Z,{className:"w-full mt-6",onClick:s,children:"хорошо"})]}):(0,a.jsx)(o.J9,{initialValues:{email:""},validate:e=>{let t={};return e.email?m.HN.test(e.email)||(t.email="Неверный формат email"):t.email="Обязательно к заполнению",t},onSubmit:(e,t)=>{let{setSubmitting:s}=t;N(""),s(!1),I({email:e.email})},children:e=>{let{values:t,handleChange:s,handleBlur:n,handleSubmit:l}=e;return(0,a.jsxs)(o.l0,{onSubmit:l,className:"flex flex-col",children:[(0,a.jsxs)(u.Z,{variant:"outlined",children:[(0,a.jsx)(x.Z,{htmlFor:"outlined-adornment-password",className:"text-subtitle1",children:"E-mail"}),(0,a.jsx)(h.Z,{inputRef:j,id:"email",name:"email",value:t.email,onChange:e=>{s(e),N("")},onBlur:n,label:"E-mail",className:"text-subtitle1"})]}),(0,a.jsx)(o.Bc,{className:"mt-2 text-subtitle2 text-red",name:"email",component:"div"}),d&&(0,a.jsx)(r.Z,{variant:"subtitle2",className:"mt-2 text-red",children:d}),(0,a.jsx)(E.Z,{type:"submit",loading:D,className:"mt-6",children:"Восстановить пароль"})]})}})]})},I=s(41664),D=s.n(I);let R={email:"",password:""};function SignInDialog(e){let{open:t,onClose:s,onSignUp:j}=e,{isMobileBreakpoint:v}=(0,A.Z)(),[w,T]=(0,n.useState)(!1),[I,Z]=(0,n.useState)(""),[S,C]=(0,n.useState)(null),[O,_]=(0,n.useState)(null),[L,k]=(0,n.useState)(!1),[y,F]=(0,n.useState)(!1),[P,U]=(0,n.useState)(!1),handleClickShowPassword=()=>k(e=>!e),handleMouseDownPassword=e=>{e.preventDefault()},nextAuthSignIn=async e=>{S&&O&&await (0,d.signIn)("credentials",{email:S,password:O,callbackUrl:e===m.vX.RETAIL||e===m.vX.SALES?"/catalogue":"/dashboard"})},{mutate:V}=c.h.users.getUserRole.useMutation({onSuccess:async e=>{let{role:t,contract:a}=null!=e?e:{};if(t===m.vX.RETAIL&&!a){s(),T(!1),U(!0);return}t&&await nextAuthSignIn(t),T(!1)},onError(e){Z(m.hv[e.message]),T(!1)}}),{mutate:B,isLoading:M}=c.h.users.acceptContractOffer.useMutation({onSuccess:async e=>{S&&O&&await (0,d.signIn)("credentials",{email:S,password:O,callbackUrl:e===m.vX.RETAIL||e===m.vX.SALES?"/catalogue":"/dashboard"}),T(!1)},onError:()=>{Z("Ошибка при соглашении с договором оферты. Попробуйте снова!"),T(!1)}});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i.Z,{fullScreen:v,open:t,onClose:s,maxWidth:!1,PaperProps:{sx:{padding:v?2:5,width:v?"100vw":"364px"}},children:[v?(0,a.jsxs)("div",{className:"relative flex items-center bg-red h-15 px-3 child:text-white -mx-4",children:[(0,a.jsx)(g.Z,{onClick:s,className:"absolute w-5 h-5",children:(0,a.jsx)(f.Z,{})}),(0,a.jsx)(r.Z,{variant:"h3",className:"flex-1 text-center",children:"Авторизация"})]}):(0,a.jsx)(r.Z,{variant:"h4",children:"Авторизация"}),(0,a.jsx)(o.J9,{initialValues:R,validate:e=>{let t={};return e.email?m.HN.test(e.email)||(t.email="Неверный формат email"):t.email="Обязательно к заполнению",e.password?e.password.length<4&&(t.password="Пароль должен содержать минимум 4 символа"):t.password="Обязательно к заполнению",t},onSubmit:(e,t)=>{let{setSubmitting:s}=t;T(!0),Z(""),s(!1),V({email:e.email,password:e.password})},children:e=>{let{values:t,handleChange:s,handleBlur:n,handleSubmit:l}=e;return(0,a.jsxs)(o.l0,{onSubmit:l,className:"mt-15 md:mt-5 flex flex-col",children:[(0,a.jsxs)(u.Z,{variant:"outlined",children:[(0,a.jsx)(x.Z,{htmlFor:"outlined-adornment-password",className:"text-subtitle1",children:"E-mail"}),(0,a.jsx)(h.Z,{id:"email",name:"email",value:t.email,onChange:e=>{C(e.target.value),s(e),Z("")},onBlur:n,label:"E-mail",className:"text-subtitle1"})]}),(0,a.jsx)(o.Bc,{className:"mt-2 text-subtitle2 text-red",name:"email",component:"div"}),(0,a.jsxs)(u.Z,{variant:"outlined",className:"mt-3",children:[(0,a.jsx)(x.Z,{htmlFor:"outlined-adornment-password",className:"text-subtitle1",children:"Пароль"}),(0,a.jsx)(h.Z,{id:"password",name:"password",type:L?"text":"password",value:t.password,onChange:e=>{_(e.target.value),s(e),Z("")},onBlur:n,endAdornment:(0,a.jsx)(N.Z,{position:"end",children:(0,a.jsx)(g.Z,{"aria-label":"toggle password visibility",onClick:handleClickShowPassword,onMouseDown:handleMouseDownPassword,edge:"end",children:L?(0,a.jsx)(p.Z,{}):(0,a.jsx)(b.Z,{})})}),label:"Пароль",className:"text-subtitle1"})]}),(0,a.jsx)(o.Bc,{className:"mt-2 text-subtitle2 text-red",name:"password",component:"div"}),I&&(0,a.jsx)(r.Z,{variant:"subtitle2",className:"mt-2 text-red",children:I}),(0,a.jsx)(E.Z,{type:"submit",loading:w,className:"mt-8 w-full",children:"войти"})]})}}),(0,a.jsxs)("div",{className:"mt-7.5 md:mt-10 flex flex-col-reverse md:flex-row md:justify-between gap-7.5",children:[(0,a.jsx)(l.Z,{variant:"text",className:"text-subtitle1",onClick:()=>{F(!0),s()},sx:{color:"black",textTransform:"none",fontWeight:"400"},children:"Забыли пароль?"}),!!j&&(0,a.jsx)(l.Z,{onClick:()=>{j&&j(),s()},variant:"text",className:"text-subtitle1",sx:{color:"black",textTransform:"none",fontWeight:"400"},children:"Зарегистрироваться"})]})]}),(0,a.jsxs)(i.Z,{open:P,onClose:()=>U(!1),maxWidth:!1,PaperProps:{sx:{padding:5,width:"364px"}},children:[(0,a.jsx)(r.Z,{variant:"h4",children:"Соглашение с условиями оферты"}),(0,a.jsxs)(r.Z,{variant:"subtitle2",className:"my-8",children:["Для продолжения работы, пожалуйста, внимательно ознакомьтесь с"," ",(0,a.jsx)(D(),{className:"text-red no-underline hover:underline",href:"/contract-offer",target:"_blank",children:"договором оферты"}),"."]}),(0,a.jsx)(E.Z,{loading:M||w,className:"w-full",onClick:()=>{T(!0),S&&B(S)},children:"Согласен"})]}),(0,a.jsx)(dialogs_ForgotPasswordDialog,{isOpen:y,onClose:()=>F(!1)})]})}},4813:function(e,t,s){var a=s(85893),n=s(83321);t.Z=e=>{let{children:t,onClick:s,variant:l="DARK",small:i,className:r="",type:o="button",disabled:d,href:c,component:m=c?"a":"button"}=e,x="enabled:cursor-pointer enabled:hover:bg-red ".concat("button"!==m?"hover:bg-red":""," rounded-lg ").concat(i?"h-9 px-3 py-2.5":"h-12 px-5 py-4"),u="bg-white text-grey4 enabled:hover:text-white ".concat(i?"":"border-solid border border-grey4 hover:border-red");return(0,a.jsx)(n.Z,{component:m,href:c,type:o,disabled:d,onClick:s,className:"".concat(r," ").concat("disabled:bg-grey2 disabled:border-none disabled:text-white"," ").concat(x," ").concat("DARK"===l?"bg-grey4 text-white border-none":u),children:t})}},14705:function(e,t,s){var a=s(85893),n=s(31812);t.Z=e=>{let{loading:t,disabled:s,onClick:l,small:i,className:r,children:o,component:d="button",type:c="button",variant:m="contained"}=e;return(0,a.jsx)(n.Z,{variant:m,component:d,loading:t,disabled:s,onClick:l,type:c,sx:{backgroundColor:"contained"===m?"#1E2023":"white",color:"contained"===m?"white":"#1E2023",borderColor:"#1E2023",borderRadius:"8px",height:i?"36px":"48px","&:hover":{backgroundColor:"#E51C2F",color:"white"}},className:r,children:o})}},44080:function(e,t,s){s.d(t,{D1:function(){return a},TF:function(){return n}});let a={UNIQUE_CONSTRAINT_VIOLATION:"UNIQUE_CONSTRAINT_VIOLATION",NOT_FOUND:"NOT_FOUND",ALREADY_EXIST:"ALREADY_EXIST",NOT_ENOUGH_POINTS:"NOT_ENOUGH_POINTS",HAVE_NO_RIGHTS:"HAVE_NO_RIGHTS",CREDIT_TRANSACTION_REQUIRED:"CREDIT_TRANSACTION_REQUIRED",NOT_VERIFIED:"NOT_VERIFIED",DELETED:"DELETED",NOT_AVAILABLE:"NOT_AVAILABLE",NOT_VALID:"NOT_VALID",BLOCKED:"BLOCKED"},n=[{message:"Attempt to exceed the transfer limit",text:"Попытка превышения лимита переводов (месячный лимит на одну карту 250 000 руб)"},{message:"Transaction to this card is prohibited.",text:"Перевод на данную карту запрещен."},{message:"Not specified or incorrect paymentid",text:"Не указан или некорректный paymentid"},{message:"Transaction amount not specified or incorrect",text:"Не указана или некорректна сумма операции"},{message:"Invalid card number",text:"Неверный номер карты"},{message:"Bank denied",text:"Отказано банком"},{message:"Rejected, without specifying the reason",text:"Отказ, без уточнения причины"},{message:"Rejected: The card is expired",text:"Отказ: Карта просрочена"},{message:"Rejected: operation is prohibited",text:"Отказ, операция запрещена"},{message:"Rejected: The card is expired",text:"Отказ: Карта просрочена"},{message:"Rejected: contact the servicing bank",text:"Отказ: свяжитесь с обслуживающим банком"},{message:"Rejected: contact the Issuer",text:"Отказ: держателю необходимо связаться с Эмитентом карты"},{message:"Rejected: wrong amount",text:"Отказ: неверная сумма"},{message:"Rejected: invalid card number",text:"Отказ: неверный номер Карты"},{message:"The requested Operation is invalid for the Card",text:"Отказ: Карта имеет ограничения"},{message:"Rejected: The card has restrictions",text:"Отказ: запрошенная Операция недопустима для Карты"},{message:"Rejected: Card not found",text:"Отказ: Карта не найдена"},{message:"Rejected: The operation is not allowed to the Holder",text:"Отказ: Операция не разрешена Держателю"},{message:"Rejected: limit exceeded",text:"Отказ: превышен лимит"},{message:"Rejected: for security reasons",text:"Отказ: по соображениям безопасности"},{message:"Rejected: Card is inactive",text:"Отказ: Карта неактивна"},{message:"-",text:"Ошибка банка"}]},26303:function(e,t,s){s.d(t,{HN:function(){return n},X4:function(){return r},cE:function(){return o},hv:function(){return l},vX:function(){return i}});var a=s(44080);let n=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]+$/i,l={[a.D1.NOT_FOUND]:"Указаны неправильные Email или пароль",[a.D1.ALREADY_EXIST]:"Пользователь уже существует",[a.D1.NOT_VERIFIED]:"Пользователь не верифицировал email",[a.D1.DELETED]:"Пользователь был удалён администратором",[a.D1.BLOCKED]:"Пользователь был заблокирован администратором"},i={ADMIN:"ADMIN",MANAGER:"MANAGER",SALES:"SALES",RETAIL:"RETAIL"},r={[i.ADMIN]:"Администратор",[i.MANAGER]:"Менеджер",[i.SALES]:"Менеджер дистрибьютора",[i.RETAIL]:"Клиент (СТО, РТО, магазин)"},o={ACTIVE:"Активен",DELETED:"Удален",BLOCKED:"Заблокирован",INACTIVE:"Неактивен",PENDING:"Приглашен"}}}]);