PageSourceSearch

https://guntex-forhandlere-danmark.lovable.app/assets/auth-cnVGefWz.js

js guntex-forhandlere-danmark.lovable.app collected 2026-10-03 03:27:53 UTC 3,083 bytes, 1 lines download raw bytes

1import{u as j,r as n,s as l,j as e,L as b}from"./main-oHYt0Fhj.js";import{T as w,I as g,B as N,L as y,t as d}from"./sonner-DMIv2Vjg.js";import{C as k,L as x}from"./crosshair-DEUnCT8b.js";function S(){const r=j(),[t,m]=n.useState("signin"),[o,p]=n.useState(""),[i,h]=n.useState(""),[c,u]=n.useState(!1);n.useEffect(()=>{l.auth.getSession().then(({data:a})=>{a.session&&r({to:"/admin"})})},[r]);async function f(a){a.preventDefault(),u(!0);try{if(t==="signup"){const{error:s}=await l.auth.signUp({email:o,password:i,options:{emailRedirectTo:`${window.location.origin}/admin`}});if(s)throw s;d.success("Konto oprettet — du kan logge ind."),m("signin")}else{const{error:s}=await l.auth.signInWithPassword({email:o,password:i});if(s)throw s;d.success("Logget ind"),r({to:"/admin"})}}catch(s){d.error(s instanceof Error?s.message:"Noget gik galt")}finally{u(!1)}}return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(w,{richColors:!0,position:"top-center"}),e.jsx("header",{className:"border-b border-border bg-card",children:e.jsx("div",{className:"mx-auto flex max-w-7xl items-center justify-between px-4 py-3",children:e.jsxs(b,{to:"/",className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:e.jsx(k,{className:"h-5 w-5"})}),e.jsx("p",{className:"font-display text-lg font-bold",children:"Guntex"})]})})}),e.jsxs("main",{className:"mx-auto max-w-md px-4 py-12",children:[e.jsx("h1",{className:"font-display text-3xl font-bold",children:t==="signin"?"Log ind":"Opret konto"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Adgang til admin og opdatering af forhandlere."}),e.jsxs("form",{onSubmit:f,className:"mt-6 space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"email",children:"Email"}),e.jsx(g,{id:"email",type:"email",autoComplete:"email",required:!0,value:o,onChange:a=>p(a.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"password",children:"Adgangskode"}),e.jsx(g,{id:"password",type:"password",autoComplete:t==="signup"?"new-password":"current-password",minLength:8,required:!0,value:i,onChange:a=>h(a.target.value)}),t==="signup"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Mindst 8 tegn."})]}),e.jsxs(N,{type:"submit",className:"w-full",disabled:c,children:[c&&e.jsx(y,{className:"h-4 w-4 animate-spin"}),t==="signin"?"Log ind":"Opret konto"]})]}),e.jsx("button",{onClick:()=>m(t==="signin"?"signup":"signin"),className:"mt-4 w-full text-sm text-primary hover:underline",children:t==="signin"?"Har du ikke en konto? Opret en":"Har du allerede en konto? Log ind"}),e.jsxs("p",{className:"mt-8 rounded-lg border border-border bg-muted/30 p-3 text-xs text-muted-foreground",children:["Den første konto skal manuelt tildeles admin-rollen i databasen (tabel ",e.jsx("code",{className:"font-mono",children:"user_roles"})," med",e.jsx("code",{className:"font-mono",children:" role = 'admin'"}),")."]})]})]})}export{S 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.