PageSourceSearch

https://www.phocus4.com.br/assets/login-DfhIpa7e.js

js phocus4.com.br collected 2026-10-09 22:03:22 UTC 6,109 bytes, 1 lines download raw bytes

1import{a as e,n as t,t as n}from"./jsx-runtime-C27Mmbu5.js";import{t as r}from"./link-hpD3utph.js";import{P as i,c as a,f as o,p as s}from"./index-BhrvR0K0.js";import{t as c}from"./loader-circle-C1u2nneP.js";import{t as l}from"./shield-check-BkKPZRT-.js";import{n as u}from"./site-header-mmdO6S_a.js";import{a as d,n as f,o as p}from"./ui-DKrj90Gj.js";import{t as m}from"./logo-B7rqbRn5.js";import{r as h}from"./edge-functions-9efZF_33.js";var g=e(t()),_=n();function v(){let e=i(),[t,n]=(0,g.useState)(`credentials`),[v,y]=(0,g.useState)(``),[b,x]=(0,g.useState)(``),[S,C]=(0,g.useState)(``),[w,T]=(0,g.useState)(null),[E,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(null),[A,j]=(0,g.useState)(0),[M,N]=(0,g.useState)(null),[P,F]=(0,g.useState)(!1);(0,g.useEffect)(()=>{if(!A)return;let e=window.setInterval(()=>j(e=>Math.max(0,e-1)),1e3);return()=>window.clearInterval(e)},[A]);let I=async(e=M,t=P)=>{let n=await h(`send-verification-code`,{email:v,phone:`00000000000`,photo_ids:[],empresa_id:t?null:e,mode:`login`,admin:t});if(!n?.ok)throw Error(n?.error||`Falha ao enviar código`);T(n.session_token),k(n.expires_at||null),j(Number(n.resend_after||60)),C(``)};return(0,_.jsxs)(`div`,{className:`min-h-screen`,children:[(0,_.jsx)(u,{}),(0,_.jsx)(`div`,{className:`mx-auto max-w-md px-4 py-16`,children:(0,_.jsxs)(`div`,{className:`rounded-3xl border border-border bg-white/90 p-8 shadow-elegant backdrop-blur`,children:[(0,_.jsx)(`div`,{className:`mb-6 flex justify-center`,children:(0,_.jsx)(m,{})}),t===`credentials`&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`h1`,{className:`text-center font-display text-2xl`,children:`Bem-vindo de volta`}),(0,_.jsx)(`p`,{className:`mt-1 text-center text-xs text-muted-foreground`,children:`Acesso para empresas e administradores`}),(0,_.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),D(!0);try{let{data:e,error:t}=await o.auth.signInWithPassword({email:v,password:b});if(t)throw t;let r=e.user.id,[{data:i},{data:a},{data:c}]=await Promise.all([o.from(`user_roles`).select(`role`).eq(`user_id`,r),o.from(`empresas`).select(`id,status`).eq(`owner_user_id`,r).maybeSingle(),o.from(`empresa_membros`).select(`empresa_id,ativo,empresas:empresa_id(status)`).eq(`user_id`,r).eq(`ativo`,!0).maybeSingle()]),l=i?.some(e=>e.role===`admin`||e.role===`super_admin`)??!1,u=a?.id??c?.empresa_id??null;F(l),N(u),await o.auth.signOut({scope:`local`}),await I(u,l),n(`otp`),s.success(l?`Código de super-admin enviado`:`Código enviado para seu email`)}catch(e){s.error(e?.message||`Não foi possível entrar`)}finally{D(!1)}},className:`mt-6 space-y-4`,children:[(0,_.jsx)(d,{label:`Email`,children:(0,_.jsx)(p,{type:`email`,value:v,onChange:e=>y(e.target.value),required:!0})}),(0,_.jsx)(d,{label:`Senha`,children:(0,_.jsx)(p,{type:`password`,value:b,onChange:e=>x(e.target.value),required:!0})}),(0,_.jsx)(f,{type:`submit`,disabled:E,className:`w-full`,children:E?(0,_.jsx)(c,{className:`h-4 w-4 animate-spin`}):`Continuar`})]})]}),t===`otp`&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`mx-auto grid h-12 w-12 place-items-center rounded-full bg-primary/10 text-primary`,children:(0,_.jsx)(l,{className:`h-6 w-6`})}),(0,_.jsx)(`h1`,{className:`mt-3 text-center font-display text-2xl`,children:`Código de acesso`}),(0,_.jsxs)(`p`,{className:`mt-1 text-center text-xs text-muted-foreground`,children:[`Enviamos um código de 6 dígitos para `,(0,_.jsx)(`b`,{children:v}),`.`]}),(0,_.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),!w||S.length!==6)return s.error(`Digite os 6 dígitos`);D(!0);try{let t=await h(`verify-code`,{session_token:w,code:S});if(!t?.ok)throw Error(t?.error||`Código inválido`);let{data:n,error:r}=await o.auth.signInWithPassword({email:v,password:b});if(r)throw r;let i=n.user.id,[{data:c},{data:l},{data:u}]=await Promise.all([o.from(`user_roles`).select(`role`).eq(`user_id`,i),o.from(`empresas`).select(`status`).eq(`owner_user_id`,i).maybeSingle(),o.from(`empresa_membros`).select(`empresa_id,permissoes,role,empresas:empresa_id(status)`).eq(`user_id`,i).eq(`ativo`,!0).maybeSingle()]);if(c?.some(e=>e.role===`admin`||e.role===`super_admin`))return e({to:`/admin/dashboard`});if((l?.status||u?.empresas?.status)===`bloqueada`)return await o.auth.signOut(),s.error(`Sua empresa está bloqueada. Entre em contato com o suporte.`);s.success(`Bem-vindo!`);let d=!!l;e({to:a(u?.permissoes,d||u?.role===`owner`)})}catch(e){s.error(e?.message||`Código inválido`)}finally{D(!1)}},className:`mt-6 space-y-4`,children:[(0,_.jsx)(`input`,{inputMode:`numeric`,autoComplete:`one-time-code`,maxLength:6,placeholder:`000000`,value:S,onChange:e=>C(e.target.value.replace(/\D/g,``).slice(0,6)),style:{fontSize:22},className:`w-full rounded-2xl border border-border bg-white px-4 py-3.5 text-center font-mono text-2xl tracking-[10px] text-slate-900 outline-none focus:border-primary focus:ring-2 focus:ring-primary/20`}),(0,_.jsx)(f,{type:`submit`,disabled:E||S.length!==6,className:`w-full`,children:E?(0,_.jsx)(c,{className:`h-4 w-4 animate-spin`}):`Confirmar e entrar`}),(0,_.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,_.jsx)(`span`,{children:O?`Expira às ${new Date(O).toLocaleTimeString(`pt-BR`,{hour:`2-digit`,minute:`2-digit`})}`:`Código válido por 10 minutos`}),(0,_.jsx)(`button`,{type:`button`,onClick:async()=>
1{if(!(A>0)){D(!0);try{await I(),s.success(`Novo código enviado para seu email`)}catch(e){s.error(e?.message||`Não foi possível reenviar o código`)}finally{D(!1)}}},disabled:E||A>0,className:`font-semibold text-primary underline disabled:text-muted-foreground disabled:no-underline`,children:A>0?`Reenviar em ${A}s`:`Reenviar código`})]}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>n(`credentials`),className:`w-full text-center text-xs text-muted-foreground underline`,children:`Voltar`})]})]}),(0,_.jsxs)(`p`,{className:`mt-6 text-center text-sm text-muted-foreground`,children:[`Quer cadastrar seu estúdio? `,(0,_.jsx)(r,{to:`/cadastro`,className:`text-primary hover:underline`,children:`Solicitar cadastro`})]})]})})]})}export{v 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.