1import{aG as j,r,j as e,aI as N,y as o,aO as g}from"./index-CzMEFmtw.js";function S(){const{user:n,isStaff:u,loading:h}=j(),[a,p]=r.useState("signin"),[i,f]=r.useState(""),[l,b]=r.useState(""),[d,y]=r.useState(""),[c,m]=r.useState(!1);if(h)return null;if(n&&u)return e.jsx(N,{to:"/admin",replace:!0});if(n&&!u)return e.jsxs(x,{children:[e.jsxs("p",{className:"text-sm text-gray-700 mb-4",children:["You're signed in as ",e.jsx("strong",{children:n.email})," but you don't have admin access."]}),e.jsx("button",{onClick:()=>o.auth.signOut(),className:"w-full h-11 rounded-lg border border-gray-300 text-sm font-semibold",children:"Sign out"})]});const w=async t=>{t.preventDefault(),m(!0);try{if(a==="signup"){const{error:s}=await o.auth.signUp({email:i,password:l,options:{emailRedirectTo:`${window.location.origin}/admin`,data:{full_name:d}}});if(s)throw s;g.success("Account created. Signing you inâ¦")}else{const{error:s}=await o.auth.signInWithPassword({email:i,password:l});if(s)throw s}}catch(s){g.error(s.message??"Something went wrong")}finally{m(!1)}};return e.jsxs(x,{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-1",children:"Healthserve Admin"}),e.jsx("p",{className:"text-sm text-gray-500 mb-6",children:a==="signin"?"Sign in to manage the website":"Create your admin account"}),e.jsxs("form",{onSubmit:w,className:"space-y-3",children:[a==="signup"&&e.jsx("input",{required:!0,placeholder:"Full name",value:d,onChange:t=>y(t.target.value),className:"w-full h-11 px-3.5 rounded-lg border border-gray-300 text-sm"}),e.jsx("input",{required:!0,type:"email",placeholder:"Email",value:i,onChange:t=>f(t.target.value),className:"w-full h-11 px-3.5 rounded-lg border border-gray-300 text-sm"}),e.jsx("input",{required:!0,type:"password",minLength:8,placeholder:"Password (min 8 chars)",value:l,onChange:t=>b(t.target.value),className:"w-full h-11 px-3.5 rounded-lg border border-gray-300 text-sm"}),e.jsx("button",{disabled:c,className:"w-full h-11 rounded-lg bg-[#F9A01B] text-white font-semibold text-sm disabled:opacity-60",children:c?"Please waitâ¦":a==="signin"?"Sign in":"Create account"})]}),e.jsx("button",{onClick:()=>p(a==="signin"?"signup":"signin"),className:"mt-4 text-xs text-gray-500 hover:text-gray-800 underline",children:a==="signin"?"Need an account? Sign up":"Already have an account? Sign in"}),e.jsx("p",{className:"mt-6 text-[11px] text-gray-400 leading-relaxed",children:"The very first person to sign up becomes admin automatically. After that, only invited users get access."})]})}const x=({children:n})=>e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center px-4",children:e.jsx("div",{className:"w-full max-w-sm bg-white rounded-2xl border border-gray-200 shadow-sm p-8",children:n})});export{S 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.