1import{r,j as e}from"./vendor-react-63GBCzgN.js";import{L as p}from"./vendor-router-DoA1Duab.js";import{b as d}from"./index-BJrnvmHL.js";import{S as x}from"./Seo-B918XYBm.js";import{B as u}from"./button-Cphulpt2.js";import"./vendor-base44-C5mCKdwd.js";import"./seo-DMoXMJ1K.js";import"./index-BD-4lBsl.js";function h({request:t,onDecided:n}){const[s,i]=r.useState(!1),[a,c]=r.useState("");async function o(l){i(!0),c("");try{const{data:m}=await d.functions.invoke("adminAccess",{action:"decide",requestId:t.id,decision:l});n(m.request)}catch(m){c(m.response?.data?.error||"Não foi possÃvel registrar a decisão.")}finally{i(!1)}}return e.jsxs("div",{className:"mt-5 space-y-4",children:[e.jsxs("p",{className:"break-all text-sm",children:["Conta: ",e.jsx("strong",{children:t.email})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Solicitado em ",new Date(t.created_date).toLocaleString("pt-BR")]}),t.status==="pending"?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm",children:"Autorize somente pessoas que você reconhece. O perfil admin continuará sendo obrigatório."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(u,{disabled:s,onClick:()=>o("approved"),children:"Aprovar acesso"}),e.jsx(u,{variant:"outline",disabled:s,onClick:()=>o("denied"),children:"Recusar"})]})]}):e.jsx("p",{role:"status",children:t.status==="approved"?"Acesso aprovado.":"Acesso recusado."}),a&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:a})]})}function k(){const[t,n]=r.useState(null),[s,i]=r.useState("");return r.useEffect(()=>{let a=!0;async function c(){try{if(!await d.auth.isAuthenticated()){window.location.href=`/admin/login?returnTo=${encodeURIComponent(window.location.pathname+window.location.search)}`;return}const o=new URLSearchParams(window.location.search).get("request"),{data:l}=await d.functions.invoke("adminAccess",{action:"review",requestId:o});a&&n(l.request)}catch(o){a&&i(o.response?.data?.error||"Não foi possÃvel abrir a solicitação.")}}return c(),()=>{a=!1}},[]),e.jsxs("main",{className:"flex min-h-screen items-center justify-center bg-background px-5",children:[e.jsx(x,{title:"Aprovação de acesso · Treeal",noindex:!0}),e.jsxs("section",{className:"w-full max-w-lg rounded-2xl border border-border bg-card p-7",children:[e.jsx("h1",{className:"text-2xl font-heading",children:"Aprovação de primeiro acesso"}),s?e.jsx("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:s}):t?e.jsx(h,{request:t,onDecided:n}):e.jsx("p",{className:"mt-4",role:"status",children:"Carregando solicitação..."}),s&&e.jsx("button",{className:"mt-4 text-sm underline",onClick:()=>d.auth.logout(`/admin/login?returnTo=${encodeURIComponent(window.location.pathname+window.location.search)}`),children:"Entrar com a conta do proprietário"}),e.jsx(p,{to:"/admin/login",className:"mt-6 block text-sm underline",children:"Voltar ao acesso administrativo"})]})]})}export{k 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.