PageSourceSearch

https://app.stoqui.com.br/assets/ChangePhoneNumberPage-BjFIiv9V.js

js stoqui.com.br collected 2026-09-24 11:57:43 UTC 4,384 bytes, 1 lines download raw bytes

1import{j as t,a7 as _,ab as j,z as V,a2 as G,T as D,N as U,ad as I}from"./mui-CRsYZxVY.js";import{r as n}from"./vendor-Dwao9eNC.js";import{y as Y,z as H,B as w,u as J,b as X,C as Z,f as M,T as ee,D as te,P as ne,E as oe,F as se,w as p,G as ae,I as O}from"./index-TALscxEc.js";import{L as k}from"./lab-DSem1Osk.js";import"./query-8ViTdhdk.js";import"./datePickers-BIJXYOKG.js";import"./icons-D8aatgQ4.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"2ad85febf9735404429b0670d4acf56a0af5a0a2"}}catch{}})();try{(function(){var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},u=new e.Error().stack;u&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[u]="776d313f-ac55-4206-9534-6b6199c648aa",e._sentryDebugIdIdentifier="sentry-dbid-776d313f-ac55-4206-9534-6b6199c648aa")})()}catch{}const re=Y().shape({phone:H().required("Novo número de telefone é obrigatório").test("is-valid-phone","Número de telefone inválido",e=>!e||w(e))}),pe=()=>{const{user:e}=J(),u=X(),[c,s]=n.useState(!1),[f,g]=n.useState(null),[S,a]=n.useState(null),[m,x]=n.useState(!1),[E,b]=n.useState(null),[r,y]=n.useState(""),[v,i]=n.useState(null),{control:$,handleSubmit:B,setValue:W,watch:L,formState:{errors:P,isValid:q,touchedFields:A}}=Z({resolver:se(re),defaultValues:{phone:""},mode:"onSubmit"}),h=L("phone"),T=!!A.phone,R=e!=null&&e.phone?M(e.phone):"",z=e!=null&&e.new_phone?M(e.new_phone):null,K=()=>{u("/profile/edit-profile?phoneChanged=true",{replace:!0})};n.useEffect(()=>{e!=null&&e.new_phone&&(b(e.new_phone),x(!0))},[e]),n.useEffect(()=>{f&&h&&g(null)},[h,f]);const Q=async o=>{if(!w(o.phone)){a("Número de telefone inválido.");return}if(s(!0),g(null),a(null),i(null),!e){s(!1);return}const l=`+${o.phone.replace(/\D/g,"")}`;if(l===e.phone||l===e.new_phone){a("Este já é o seu número de telefone atual ou pendente."),s(!1);return}try{const{error:d}=await p.auth.updateUser({phone:l});d?a(`Erro ao solicitar alteração: ${ae(d.message)}`):(b(l),x(!0),y(""),await p.auth.refreshSession(),O.invalidateQueries({queryKey:["user"]}))}catch(d){a(`Erro inesperado: ${d.message}`)}s(!1)},C=async()=>{if(!E||r.length!==6){i("Código OTP deve ter 6 dígitos.");return}s(!0),i(null),g(null),a(null);try{const{error:o}=await p.auth.verifyOtp({phone:E,token:r,type:"phone_change"});o?(i(`Código inválido ou expirado: ${o.message}`),y(""),s(!1)):(await p.auth.refreshSession(),O.invalidateQueries({queryKey:["user"]}),K())}catch(o){i(`Erro inesperado: ${o.message}`),s(!1)}};return n.useEffect(()=>{r.length===6&&m&&C()},[r,m]),t.jsxs(_,{sx:{pb:4},children:[t.jsx(ee,{title:"Alterar número de telefone",navigateBack:!0}),t.jsx(_,{sx:{p:2},children:t.jsxs(j,{spacing:3,children:[t.jsx(V,{value:R,label:"Telefone atual",fullWidth:!0,variant:"outlined",disabled:!0}),m?t.jsxs(t.Fragment,{children:[t.jsx(V,{value:z||"",label:"Novo número de telefone",fullWidth:!0,variant:"outlined",disabled:!0}),t.jsx(G,{sx:{mt:2,mb:2},children:t.jsx(D,{variant:"body2",color:"text.secondary",children:"Confirme o código recebido por SMS"})}),t.jsxs(j,{spacing:2,alignItems:"center",children:[t.jsx(oe,{value:r,autoFocus:!0,onChange:y,length:6,sx:{gap:1,maxWidth:"350px"},TextFieldsProps:{disabled:c,error:!!v,type:"tel",inputMode:"numeric"}}),v&&t.jsx(D,{color:"error",variant:"body2",sx:{mt:1},children:v}),t.jsx(k,{onClick:C,variant:"contained",color:"primary",loading:c,disabled:r.length!==6,fullWidth:!0,sx:{mt:2},children:"Verificar código"}),t.jsx(U,{variant:"text",onClick:()=>{x(!1),b(null),a(null),i(null),W("phone","")},disabled:c,children:"Cancelar ou alterar número"})]})]}):t.jsx("form",{onSubmit:B(Q),children:t.jsxs(j,{spacing:2,children:[t.jsx(te,{name:"phone",control:$,render:({field:{ref:o,value:F,onChange:l,onBlur:d}})=>{var N;return t.jsx(ne,{inputRef:o,value:F||"",onChange:l,onBlur:d,disabled:c,lockPrefix:!0,label:"Novo número de telefone",fullWidth:!0,autoFocus:!0,error:T&&!!P.phone,helperText:T?(N=P.phone)==null?void 0:N.message:""})}}),t.jsx(k,{type:"submit",variant:"contained",loading:c,fullWidth:!0,disabled:!q||!h||!w(h),children:"Enviar SMS de confirmação"})]})}),f&&t.jsx(I,{severity:"success",sx:{mt:2},children:f}),S&&t.jsx(I,{severity:"error",sx:{mt:2},children:S})]})})]})};export{pe as default};

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.