1import{h,u as g,j as e}from"./index-D_T1XJ3U.js";import{d as p,e as u,r as l}from"./vendor-react-Bxgxa9T6.js";function v(){const{user:t}=h(),c=g(),d=p(),[m]=u(),[i,a]=l.useState({kind:"idle"}),o=m.get("q")||"";return l.useEffect(()=>{if(!(!t||t.role!=="admin")){if(!o){a({kind:"error",message:"Falta el parámetro ?q=email_o_nombre en la URL."});return}a({kind:"running"}),c("/api/admin/end-trial",{method:"POST",body:JSON.stringify({q:o})}).then(async r=>{const n=await r.json().catch(()=>({}));r.ok?a({kind:"ok",user:n.user}):(n==null?void 0:n.error)==="multiple_matches"?a({kind:"error",message:"Múltiples coincidencias. Especificá más:",candidates:n.candidates}):(n==null?void 0:n.error)==="no_match"?a({kind:"error",message:`No encontré users en trial que coincidan con "${o}". Quizás ya pagó o el email/nombre no matchea.`}):a({kind:"error",message:(n==null?void 0:n.error)||`Error HTTP ${r.status}`})}).catch(r=>a({kind:"error",message:(r==null?void 0:r.message)||"Error de red"}))}},[o,t==null?void 0:t.id]),t?t.role!=="admin"?e.jsx(s,{children:e.jsx("div",{style:{color:"#EF4444"},children:"Solo admin. Tu cuenta no tiene permiso."})}):e.jsxs(s,{children:[e.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#737373",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:8},children:"Herramienta admin · Cerrar trial"}),e.jsxs("div",{style:{fontSize:13,color:"#525252",marginBottom:20},children:["Buscando: ",e.jsx("code",{style:x,children:o||"(sin query)"})]}),i.kind==="running"&&e.jsx("div",{style:{color:"#737373",fontSize:14},children:"Procesandoâ¦"}),i.kind==="ok"&&e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:22,fontWeight:800,color:"#10B981",margin:"0 0 12px"},children:"â Trial terminado"}),e.jsxs("p",{style:{fontSize:14,color:"#3F3F3F",lineHeight:1.55,margin:"0 0 8px"},children:["Cerré el trial de ",e.jsx("b",{children:i.user.email}),i.user.name?` (${i.user.name})`:""," ",e.jsxs("span",{style:{color:"#737373"},children:["· id ",i.user.id]}),"."]}),e.jsx("p",{style:{fontSize:13,color:"#737373",lineHeight:1.55,margin:"0 0 18px"},children:"En su próximo login va a ver la pantalla de trial vencido y deberá pagar para seguir usando."}),e.jsx("button",{onClick:()=>d("/"),style:f,children:"Ir al dashboard"})]}),i.kind==="error"&&e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:20,fontWeight:800,color:"#EF4444",margin:"0 0 10px"},children:"No se pudo ejecutar"}),e.jsx("p",{style:{fontSize:14,color:"#3F3F3F",lineHeight:1.55,margin:"0 0 14px"},children:i.message}),i.candidates&&i.candidates.length>0&&e.jsx("ul",{style:{paddingLeft:18,margin:"0 0 18px",fontSize:13,color:"#3F3F3F"},children:i.candidates.map(r=>e.jsxs("li",{style:{marginBottom:6},children:[e.jsx("b",{children:r.email})," ",r.name?`· ${r.name}`:""," ",e.jsxs("span",{style:{color:"#737373"},children:["(id ",r.id,")"]})]},r.id))}),e.jsx("button",{onClick:()=>d("/"),style:y,children:"Volver"})]})]}):e.jsx(s,{children:e.jsx("div",{children:"Necesitas iniciar sesión."})})}function s({children:t}){return e.jsx("div",{style:{minHeight:"100vh",background:"var(--bg-primary)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:e.jsx("div",{style:{background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:16,padding:32,maxWidth:520,width:"100%",boxShadow:"var(--shadow-md)"},children:t})})}const x={background:"var(--bg-tertiary)",padding:"2px 8px",borderRadius:6,fontFamily:"monospace",fontSize:12,color:"var(--text-primary)"},f={padding:"10px 18px",fontSize:13,fontWeight:700,fontFamily:"inherit",background:"linear-gradient(135deg, #6366F1, #A855F7)",color:"#fff",border:"none",borderRadius:10,cursor:"pointer"},y={padding:"10px 18px",fontSize:13,fontWeight:700,fontFamily:"inherit",background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border)",borderRadius:10,cursor:"pointer"};export{v as AdminEndTrialPage};
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.