PageSourceSearch

https://bolsa-de-trabajo-upy.lovable.app/assets/auth-Co_LH1v0.js

js bolsa-de-trabajo-upy.lovable.app collected 2026-10-03 03:24:32 UTC 4,832 bytes, 1 lines download raw bytes

1import{R as k,i as R,h as B,r as o,j as e,k as p,B as P,f as I,L,s as x,t as h}from"./index-BbGE8qkG.js";import{S as $}from"./SiteHeader-D8I_CEt1.js";import{I as v}from"./input-CSJwpke0.js";import{C as _}from"./card-Ds54rD6_.js";import{G as A}from"./graduation-cap-Bs8SWSV0.js";import{B as U}from"./briefcase-CWdg0wKY.js";import{B as W}from"./building-2-BIjueyg7.js";import"./index-DYh2uD_S.js";function g(t){return!t||!t.startsWith("/")||t.startsWith("//")?null:t}function V(){const t=k.useSearch(),c=R(),{user:f,role:i,loading:b}=B(),[s,w]=o.useState(t.mode??"signin"),[n,l]=o.useState(t.role??"student"),[u,C]=o.useState(""),[m,S]=o.useState(""),[j,y]=o.useState(!1);o.useEffect(()=>{if(!b&&f&&i){const a=g(t.next);if(a){window.location.href=a;return}c({to:i==="company"?"/dashboard/company":i==="admin"?"/admin":i==="graduate"?"/dashboard/graduate":"/dashboard/student"})}},[f,i,b,c,t.next]);const E=async a=>{a.preventDefault(),y(!0);try{if(s==="signup"){const{data:r,error:d}=await x.auth.signUp({email:u,password:m,options:{emailRedirectTo:`${window.location.origin}/auth${g(t.next)?`?next=${encodeURIComponent(g(t.next))}`:""}`}});if(d)throw d;if(r.user){const{error:N}=await x.rpc("assign_signup_role",{_user_id:r.user.id,_role:n});if(N)throw N;h.success(r.session?"¡Cuenta creada! Completa tu perfil.":"Cuenta creada. Revisa tu correo para confirmar tu acceso."),r.session&&c({to:n==="company"?"/onboarding/company":n==="graduate"?"/onboarding/graduate":"/onboarding/student"})}}else{const{error:r}=await x.auth.signInWithPassword({email:u,password:m});if(r)throw r;h.success("Bienvenido de nuevo")}}catch(r){const d=r instanceof Error?r.message:"Error inesperado";h.error(d)}finally{y(!1)}};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx($,{}),e.jsx("div",{className:"container mx-auto flex items-center justify-center px-4 py-12",children:e.jsxs(_,{className:"w-full max-w-md p-8",children:[e.jsxs("div",{className:"mb-6 text-center",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s==="signup"?"Crear cuenta":"Iniciar sesión"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s==="signup"?"Únete a UPY Connect":"Accede a tu panel de UPY Connect"})]}),s==="signup"&&e.jsxs("div",{className:"mb-5",children:[e.jsx(p,{className:"mb-2 block text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Soy"}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>l("student"),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-3 transition-all ${n==="student"?"border-primary bg-primary/5 text-primary":"border-border text-muted-foreground hover:border-primary/40"}`,children:[e.jsx(A,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Estudiante"})]}),e.jsxs("button",{type:"button",onClick:()=>l("graduate"),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-3 transition-all ${n==="graduate"?"border-primary bg-primary/5 text-primary":"border-border text-muted-foreground hover:border-primary/40"}`,children:[e.jsx(U,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Egresado"})]}),e.jsxs("button",{type:"button",onClick:()=>l("company"),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-3 transition-all ${n==="company"?"border-primary bg-primary/5 text-primary":"border-border text-muted-foreground hover:border-primary/40"}`,children:[e.jsx(W,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Empresa"})]})]})]}),e.jsxs("form",{onSubmit:E,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{htmlFor:"email",children:"Correo"}),e.jsx(v,{id:"email",type:"email",required:!0,value:u,onChange:a=>C(a.target.value),placeholder:"[email protected]",autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsx(p,{htmlFor:"password",children:"Contraseña"}),e.jsx(v,{id:"password",type:"password",required:!0,minLength:6,value:m,onChange:a=>S(a.target.value),placeholder:"Mínimo 6 caracteres",autoComplete:s==="signup"?"new-password":"current-password"})]}),e.jsxs(P,{type:"submit",variant:"hero",size:"lg",className:"w-full",disabled:j,children:[j&&e.jsx(I,{className:"animate-spin"}),s==="signup"?"Crear cuenta":"Entrar"]})]}),e.jsxs("div",{className:"mt-6 text-center text-sm text-muted-foreground",children:[s==="signup"?"¿Ya tienes cuenta?":"¿Aún no tienes cuenta?"," ",e.jsx("button",{className:"font-medium text-primary hover:underline",onClick:()=>w(s==="signup"?"signin":"signup"),children:s==="signup"?"Inicia sesión":"Regístrate"})]}),e.jsx("div",{className:"mt-2 text-center",children:e.jsx(L,{to:"/",className:"text-xs text-muted-foreground hover:underline",children:"← Volver al inicio"})})]})})]})}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.