PageSourceSearch

https://en.b2b.cafe/assets/login_phone-DEbY39ZP.js

js b2b.cafe collected 2026-09-24 14:35:59 UTC 12,857 bytes, 1 lines download raw bytes

1import{r as m,u as e,af as B,b5 as H,bC as $,bD as q,bE as z}from"./vendor-DzWMmZj2.js";import{p as G,o as _,u as T,d as K}from"./vendor-tanstack-D-s8FawA.js";import{H as Q,a,I as J,J as X,K as Y,T as Z,Q as L,L as A,z as P,B as C,l as S,M as ee,N as te}from"./index-B-ZZKIlh.js";import{i as N,s as E,a as O,v as U,A as ne}from"./validators-5Tgu1LNi.js";import{a as se,w as D,u as oe}from"./useForm-DkZRU2IA.js";import{S as re}from"./StatusCard-BsnPiwJk.js";import{u as y}from"./vendor-i18n-C7hD56hb.js";import"./vendor-socket-CdJ84v18.js";import"./vendor-phone-CDRp5aFf.js";import"./date-picker-Ci6ABAHb.js";const ae=o=>"Выслать код повторно через ".concat(Q(o)),k=(o=0)=>o-Math.ceil(Date.now()/1e3),ie=(o=Date.now(),n=60)=>Math.ceil(o/1e3)+n,le=({blockTo:o,formatMessage:n=ae,children:i})=>{const[l,t]=m.useState(()=>k(o));return m.useLayoutEffect(()=>{const d=Math.max(k(o),0);if(t(d),d<=0)return;const p=setInterval(()=>{t(x=>x>0?x-1:(clearInterval(p),0))},1e3);return()=>clearInterval(p)},[o]),l<=0?i:e.jsx("div",{className:"flex justify-center items-center h-9 text-conte-body-l text-center align-middle",children:n(l)})},ce=({classNames:o,...n})=>{const{t:i}=y(["auth","common"]);return e.jsx(Z,{...n,classNames:{...o,trigger:"h-full"},children:e.jsxs("div",{className:a("flex flex-col gap-1 text-conte-body-l text-center text-foreground"),children:[e.jsx("div",{className:a("text-center text-foreground"),children:i("auth.login_phone.wait_activation")}),e.jsx(L,{children:l=>e.jsxs("div",{className:a("text-center text-foreground"),children:[i("auth.login_phone.have_questions")," — ",l]})})]})})},de=({isActive:o})=>{const{t:n}=y(["auth","common"]),{isMobile:i}=Y();return i?e.jsx("div",{className:a("h-fit w-fit px-1 uppercase text-conte-tag",o?"text-success":"text-warning"),children:o?e.jsx(H,{className:"size-4.5"}):e.jsx($,{className:"size-4.5"})}):e.jsx("div",{className:a("h-fit w-fit px-1 uppercase text-conte-tag rounded-[12px] border border-current",o?"text-success":"text-warning"),children:n(o?"auth.login_phone.users.active":"auth.login_phone.users.waiting")})},ue=({user:o,onClick:n})=>e.jsxs("div",{className:a("w-full px-3 py-2 rounded-[12px]","flex flex-row gap-3",o.isActive?"bg-border hover:bg-gray-hover cursor-pointer":"bg-light-primary hover:bg-light-primary-hover cursor-not-allowed"),onClick:()=>{o.isActive&&(n==null||n(o))},children:[e.jsx(J,{className:"mt-1 bg-primary size-11.5 text-conte-heading3",children:e.jsx(X,{className:"bg-primary text-primary-foreground",children:o.initial})}),e.jsxs("div",{className:a("flex-1 flex flex-col"),children:[e.jsxs("div",{className:a("w-full flex flex-row"),children:[e.jsx("div",{className:a("text-conte-body-l"),children:o.name}),e.jsxs("div",{className:a("ml-auto h-6 flex flex-row items-center gap-1.5"),children:[e.jsx(de,{isActive:o.isActive||!1}),o.isActive?e.jsx(B,{className:"size-4"}):e.jsx(ce,{})]})]}),e.jsx("div",{className:a("text-conte-input text-muted-foreground"),children:o==null?void 0:o.company}),e.jsx("div",{className:a("text-conte-input text-muted-foreground"),children:o==null?void 0:o.email})]})]}),W=G({defaultValues:{step:1,lastCodeSentAt:0,phone:"",country:null,resend:!1,code:"",user:null,phoneWithFormat:"",phoneWithoutDial:""}}),F={1:["step","lastCodeSentAt","phone","country","phoneWithoutDial","phoneWithFormat"],2:["step","lastCodeSentAt","phone","country","resend","code","phoneWithFormat"],3:["step","lastCodeSentAt","phone","country","user","phoneWithFormat"]},u={PHONE:1,CODE:2,USERS:3,ERROR_NO_REGISTERED:100},he=se({...W,props:{onBack:()=>{},onReset:()=>{}},render:function({form:n,onBack:i,onReset:l}){const{t}=y(["auth","common"]),{phone:d}=_(n.store,p=>{const x=p.values;return{phone:x==null?void 0:x.phoneWithFormat}});return e.jsxs(re,{icon:e.jsx(z,{className:a("text-error")}),title:t("auth.login_phone.errors.no_users.title"),onBack:i,children:[e.jsxs("div",{className:a("w-full"),children:[t("auth.login_phone.errors.no_users.phone.before"),e.jsx("span",{className:a("font-bold"),children:d}),t("auth.login_phone.errors.no_users.phone.after")]}),e.jsxs("div",{className:a("w-full flex gap-2"),children:[t("auth.login_phone.errors.no_users.try_login.question")," ",e.jsx(A,{to:"/login_phone",onClick:l,className:a("text-conte-body-l text-center"),children:t("auth.login_phone.errors.no_users.try_login.action")})]}),e.jsxs("div",{className:a("w-full flex gap-2"),children:[t("auth.login_phone.errors.no_users.register.question")," ",e.jsxs(A,{to:"/register",className:a("text-conte-body-l text-center"),children:[e.jsx(q,{strokeWidth:2.5,className:a("size-4 inline-block")}),t("auth.login_phone.errors.no_users.register.action")]})]}),e.jsx(L,{children:p=>e.jsxs("div",{className:a("mt-2"),children:[e.jsx("div",{children:t("auth.login_phone.errors.no_users.contact.question")}),e.jsxs("div",{className:a("w-full flex gap-2 flex-wrap"),children:[t("auth.login_phone.errors.no_users.contact.action")," — ",p]})]})})]})}}),{securityLoginPhone:me}=P(),w=["code"],pe=D({props:{onSubmit:()=>{},onBack:()=>{}},render:function({group:n,onSubmit:i,onBack:l}){const{t}=y(["auth","common"]),d=m.useRef(!1),{isSubmitting:p,isValid:x}=_(n.form.store,r=>{const c=N(r.fieldMeta,w);return{isSubmitting:r.isSubmitting,isValid:c,isFieldsValidating:n.form.state.isFieldsValidating,fieldMeta:r.fieldMeta,errors:Object.values(r.fieldMeta).flatMap(f=>f.errors)}}),{values:j,lastCodeSentAt:v}=_(n.form.store,r=>{const c=r.values;return{values:c,lastCodeSentAt:c.lastCodeSentAt}}),h=m.useMemo(()=>ie(v),[v]),b=m.useCallback(async()=>{n.clearFieldValues("code",{dontValidate:!0}),n.setFieldValue("lastCodeSentAt",Date.now());try{await me({country:j.country,phone:j.phone,resend:j.resend}),d.current=!1}catch(r){E(n,r==null?void 0:r.data)}},[j,n]),s=async()=>{await U(n.form,w),N(n.form.state.fieldMeta,w)&&(i==null||i())};return m.useLayoutEffect(()=>{n.clearFieldValues("code",{dontValidate:!0})},[n]),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:a("flex flex-col items-center"),children:e.jsx(C,{variant:"link",onClick:l,className:"text-conte-body-l  w-fit justify-center",children:t("auth.login_phone.code.change_phone")})}),e.jsx(n.AppField,{name:"code",listeners:{onChange:({value:r})=>{"".concat(r).length<4||d.current||(d.current=!0,s())}},validators:{onChange:({value:r,fieldApi:c})=>{if(c.state.meta.isTouched){if(O(r))return t("common:common.errors.required");if(d.current&&"".concat(r).length<4)return t("auth.errors.code_bad_strlen")}}},children:r=>e.jsx(r.FormCode,{centered:!0,autoComplete:"one-time-code",onChange:c=>{n.setFieldValue("code",c)}})}),e.jsx(le,{blockTo:h,formatMessage:r=>t("auth.login_phone.code.time_countdown",{time:r}),children:e.jsx(C,{variant:"link",onClick:b,className:"text-conte-body-l self-center w-fit h-fit",children:t("auth.login_phone.code.resend")})}),e.jsx("div",{className:a("flex flex-col items-center mt-4.5 gap-4.5"),children:e.jsx(C,{onClick:s,loading:!!p,disabled:!x,children:t("auth.login_phone.code.submit")})})]})}}),R=["country","phone"],xe=D({props:{onSubmit:()=>{}},render:function({group:n,onSubmit:i}){var v;const{t:l}=y(["auth","common"]),d=(v=T().state)==null?void 0:v.from,{isSubmitting:p,isValid:x}=_(n.form.store,h=>{const b=N(h.fieldMeta,R);
1return{isSubmitting:h.isSubmitting,isValid:b,fieldMeta:h.fieldMeta,errors:Object.values(h.fieldMeta).flatMap(s=>s.errors)}}),j=async()=>{await U(n.form,R),N(n.form.state.fieldMeta,R)&&(i==null||i())};return e.jsxs(e.Fragment,{children:[e.jsx(n.AppField,{name:"country",validators:{onChange:({value:h})=>{if(O(h))return l("common.errors.required")}},children:()=>e.jsx(e.Fragment,{})}),e.jsx(n.AppField,{name:"phone",listeners:{onChange:({fieldApi:h})=>{h.form.validateField("country","change")}},validators:{onChange:({value:h})=>{if(O(h))return l("auth.errors.phone_empty")}},children:h=>e.jsx(h.FormPhone,{centered:!0,autoComplete:"tel",onChange:(b,s)=>{var r,c;S.debug("Phone:",s),s!=null&&s.phone&&(n.setFieldValue("phone",s==null?void 0:s.phone),n.setFieldValue("phoneWithoutDial",s==null?void 0:s.inputValue),s!=null&&s.country&&(n.setFieldValue("phoneWithFormat","".concat((r=s==null?void 0:s.country)==null?void 0:r.dialCode," ").concat(s==null?void 0:s.inputValue)),n.setFieldValue("country",((c=s==null?void 0:s.country)==null?void 0:c.id)||null)))}})}),e.jsxs("div",{className:a("flex flex-col items-center mt-4.5 gap-10.5"),children:[e.jsx(C,{onClick:j,loading:!!p,disabled:!x,children:l("auth.login_phone.phone.submit")}),e.jsx(A,{to:"/login",state:d?{from:d}:void 0,className:"text-conte-body-l justify-center",children:l("auth.login_phone.phone.login")})]})]})}}),fe=D({props:{users:null,onSubmit:()=>{}},render:function({group:n,users:i,onSubmit:l}){return m.useLayoutEffect(()=>{if(!i||i.length!==1)return;const[t]=i||[];t!=null&&t.isActive&&(n.setFieldValue("user",t==null?void 0:t.id),l==null||l())},[n,i,l]),e.jsx("div",{className:a("flex flex-col gap-2"),children:i==null?void 0:i.map(t=>e.jsx(ue,{user:t,onClick:({id:d})=>{n.setFieldValue("user",d),l==null||l()}},t.id))})}}),V=o=>o!=null&&o.length?Object.fromEntries(o.map(n=>[n,n])):{},{securityLoginPhone:ge,securityLoginCode:ve,securityLoginSelectUser:je}=P(),be=({step:o})=>{const{t:n}=y(["auth","common"]);if(o===u.PHONE)return n("auth.login_phone.phone.title");if(o===u.CODE)return n("auth.login_phone.code.title");if(o===u.USERS)return n("auth.login_phone.users.title")},ye=({step:o,phone:n,users:i})=>{var t;const{t:l}=y(["auth","common"]);if(o!==u.PHONE){if(o===u.CODE)return e.jsxs("div",{className:a("w-full"),children:[l("auth.login_phone.code.subtitle.phone.before"),e.jsx("span",{className:a("font-bold"),children:n}),l("auth.login_phone.code.subtitle.phone.after")]});if(o===u.USERS&&(i==null?void 0:i.length)===1&&!((t=i[0])!=null&&t.isActive))return e.jsxs("div",{className:a("w-full"),children:[l("auth.login_phone.users.subtitle.phone.wait_activation.before"),e.jsx("span",{className:a("font-bold"),children:n}),l("auth.login_phone.users.subtitle.phone.wait_activation.after")]});if(o===3)return e.jsxs("div",{className:a("w-full"),children:[l("auth.login_phone.users.subtitle.phone.before"),e.jsx("span",{className:a("font-bold"),children:n}),l("auth.login_phone.users.subtitle.phone.after")]})}};function Se(){const o=K({from:"/login_phone"}),n=T(),[i,l]=m.useState(null),t=oe({...W,validators:{onSubmit:()=>null},onSubmit:async({value:s})=>{S.debug("Submitting:",s)}}),{step:d,phoneWithFormat:p,errors:x}=_(t.store,s=>{const r=s.values;return{step:r==null?void 0:r.step,phoneWithFormat:r==null?void 0:r.phoneWithFormat,errors:s==null?void 0:s.errors}}),j=m.useCallback(async()=>{const s=t.state.values;S.debug("Submitting:",s.step,s);try{await ge({country:s.country,phone:s.phone,resend:s.resend}),t.setFieldValue("step",u.CODE),t.setFieldValue("lastCodeSentAt",Date.now());return}catch(r){E(t,r==null?void 0:r.data)}},[t]),v=m.useCallback(async()=>{var r;const s=t.state.values;S.debug("Submitting:",s.step,s);try{const c=await je({country:s.country,phone:s.phone,user:s.user});if(!ee(c.result))return;const f=(r=n.state)==null?void 0:r.from,g=te(f);o({to:g,replace:!0});return}catch(c){E(t,c==null?void 0:c.data)}},[t,o,n]),h=m.useCallback(async()=>{var r;const s=t.state.values;S.debug("Submitting:",s.step,s);try{const c=await ve({country:s.country,phone:s.phone,code:s.code}),f=((r=c==null?void 0:c.result)==null?void 0:r.users)||[];if(f.sort((M,I)=>M.isActive===I.isActive?0:M.isActive?-1:1),l(f),!(f!=null&&f.length)){t.setFieldValue("step",u.ERROR_NO_REGISTERED);return}if(f.length>1){t.setFieldValue("step",u.USERS);return}const[g]=f||[];if(!(g!=null&&g.id))return;if(!(g!=null&&g.isActive)){t.setFieldValue("step",u.USERS);return}t.setFieldValue("user",g==null?void 0:g.id),v();return}catch(c){E(t,c==null?void 0:c.data)}},[v,t]),b=m.useCallback(()=>{const r=t.state.values.step||0;return[u.ERROR_NO_REGISTERED,u.USERS,u.CODE].includes(r)?(t.clearFieldValues("code",{dontValidate:!0}),t.setFieldMeta("code",c=>({...c,errorMap:{onChange:void 0},errorSourceMap:{onChange:"field"},isTouched:!1})),t.setFieldValue("step",u.PHONE)):o({to:"/"})},[t,o]);return d===u.ERROR_NO_REGISTERED?e.jsx(he,{form:t,onBack:b,onReset:()=>{t.reset()}}):e.jsx(ne,{title:e.jsx(be,{step:d}
1),subtitle:e.jsx(ye,{step:d,phone:p,users:i}),globalError:e.jsx(t.AppForm,{children:e.jsx(t.FormError,{})}),onBack:b,children:e.jsxs("form",{onSubmit:s=>{s.preventDefault(),t.handleSubmit()},className:a("flex-1 flex flex-col gap-6"),children:[e.jsx(m.Activity,{mode:d===u.PHONE?"visible":"hidden",children:e.jsx(xe,{form:t,fields:V(F[u.PHONE]),onSubmit:j})}),e.jsx(m.Activity,{mode:d===u.CODE?"visible":"hidden",children:e.jsx(pe,{form:t,fields:V(F[u.CODE]),onSubmit:h,onBack:b})}),e.jsx(m.Activity,{mode:d===u.USERS?"visible":"hidden",children:e.jsx(fe,{form:t,users:i,fields:V(F[u.USERS]),onSubmit:v})})]})})}const De=Se;export{De as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.