1import{u as b,r as o,s as c,j as e,t as n}from"./index-Bapv0dFw.js";import{S as y,L as m,I as g,a as j}from"./site-footer-D6DHP7wK.js";import{B as v}from"./use-events-nMem5JPs.js";function E(){const d=b(),[a,x]=o.useState(""),[l,p]=o.useState(""),[t,f]=o.useState("signin"),[u,i]=o.useState(!1),h=async()=>{if(!a){n.error("Enter your email above first, then click 'Forgot password?'");return}i(!0);try{const{error:s}=await c.auth.resetPasswordForEmail(a,{redirectTo:`${window.location.origin}/reset-password`});if(s)throw s;n.success("Password reset email sent. Check your inbox.")}catch(s){n.error(s instanceof Error?s.message:"Failed to send reset email")}finally{i(!1)}};o.useEffect(()=>{c.auth.getSession().then(({data:{session:s}})=>{s&&d({to:"/admin"})})},[d]);const w=async s=>{s.preventDefault(),i(!0);try{if(t==="signup"){const{error:r}=await c.auth.signUp({email:a,password:l,options:{emailRedirectTo:`${window.location.origin}/admin`}});if(r)throw r;n.success("Check your email to confirm your account.")}else{const{error:r}=await c.auth.signInWithPassword({email:a,password:l});if(r)throw r;n.success("Signed in."),d({to:"/admin"})}}catch(r){n.error(r instanceof Error?r.message:"Failed")}finally{i(!1)}};return e.jsxs("div",{className:"min-h-screen flex flex-col",children:[e.jsx(y,{}),e.jsx("main",{className:"flex-1 container mx-auto px-4 py-16 max-w-md",children:e.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[e.jsx("h1",{className:"text-2xl font-bold mb-1",children:t==="signin"?"Admin sign in":"Create account"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:"Manage events for SportsAnnouncing.com."}),e.jsxs("form",{onSubmit:w,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:"email",children:"Email"}),e.jsx(g,{id:"email",type:"email",required:!0,value:a,onChange:s=>x(s.target.value),autoComplete:"email"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(m,{htmlFor:"password",children:"Password"}),t==="signin"&&e.jsx("button",{type:"button",onClick:h,disabled:u,className:"text-xs text-muted-foreground hover:text-foreground underline",children:"Forgot password?"})]}),e.jsx(g,{id:"password",type:"password",required:!0,minLength:6,value:l,onChange:s=>p(s.target.value),autoComplete:t==="signin"?"current-password":"new-password"})]}),e.jsx(v,{type:"submit",disabled:u,className:"w-full",children:u?"Workingâ¦":t==="signin"?"Sign in":"Sign up"})]}),e.jsx("button",{type:"button",className:"mt-4 text-sm text-muted-foreground hover:text-foreground",onClick:()=>f(t==="signin"?"signup":"signin"),children:t==="signin"?"Need an account? Create one":"Already have an account? Sign in"}),t==="signup"&&e.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"The first account you create needs to be granted admin access â contact support after signup if you don't see admin tools."})]})}),e.jsx(j,{})]})}export{E 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.