1import{F as G,r as t,G as H,j as e,m as x,g as $,B as S,L,v as z,J as n,K as l,O as J}from"./index-BrloFnwe.js";const h={initial:{opacity:0,y:30},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.6}},K=[{value:"huvud",label:"Huvudmedlem",price:"200 kr/år"},{value:"familj",label:"Familjemedlem",price:"100 kr/år"}],_=({data:r})=>{const i=r.options&&r.options.length>0?r.options:K,[d,C]=G(),F=d.get("typ")??i[0].value,[o,g]=t.useState(F),[p,E]=t.useState(""),[c,P]=t.useState(""),[j,T]=t.useState(""),[f,q]=t.useState(""),[m,A]=t.useState(""),[v,B]=t.useState(""),[y,I]=t.useState(""),[b,u]=t.useState(""),[V,O]=t.useState(!1),[N,k]=t.useState(!1),{signUp:U}=H();t.useEffect(()=>{const s=d.get("typ");s&&i.some(a=>a.value===s)&&g(s)},[d,i]),t.useEffect(()=>{if(typeof window<"u"&&window.location.hash==="#anmalan"){const s=document.getElementById("anmalan");s&&setTimeout(()=>s.scrollIntoView({behavior:"smooth",block:"start"}),100)}},[]);const w=i.find(s=>s.value===o)??i[0],R=s=>{g(s);const a=new URLSearchParams(d);a.set("typ",s),C(a,{replace:!0})},D=async s=>{if(s.preventDefault(),u(""),!/^\d{3}\s?\d{2}$/.test(m.trim())){u("Ange ett giltigt postnummer (5 siffror).");return}k(!0);const{error:a}=await U(c,y,p,j,f.trim(),m.trim(),v.trim(),o);k(!1),a?u(a.message):O(!0)};return e.jsx("section",{id:"anmalan",className:`section-pad scroll-mt-24 ${r.bg_color||"bg-background"}`,children:e.jsxs("div",{className:"section-shell max-w-2xl",children:[e.jsxs(x.div,{...h,className:"text-center mb-10",children:[e.jsx("h2",{className:"heading-editorial text-3xl md:text-4xl text-foreground mb-4",children:r.title??"Ansök om medlemskap"}),r.description&&e.jsx("p",{className:"text-foreground/80 text-lg leading-relaxed",children:r.description})]}),V?e.jsxs(x.div,{...h,className:"bg-secondary rounded-2xl p-8 md:p-10 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-primary/10",children:e.jsx($,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"font-serif text-2xl text-foreground mb-3",children:"Tack för din ansökan!"}),e.jsxs("p",{className:"text-foreground/80 leading-relaxed mb-6",children:["Vi har skickat ett verifieringsmail till ",e.jsx("strong",{children:c}),". Verifiera din e-post och invänta sedan godkännande från styrelsen."]}),e.jsx(S,{asChild:!0,variant:"outline",className:"rounded-full px-8",children:e.jsx(L,{to:"/",children:"Tillbaka till startsidan"})})]}):e.jsxs(x.div,{...h,className:"bg-secondary rounded-2xl p-6 md:p-10",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground mb-3",children:"Välj typ av medlemskap"}),e.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:i.map(s=>{const a=s.value===o;return e.jsxs("button",{type:"button",onClick:()=>R(s.value),className:z("rounded-xl border-2 p-4 text-left transition-colors",a?"border-primary bg-background":"border-transparent bg-background/60 hover:bg-background"),children:[e.jsx("div",{className:"font-serif text-lg text-foreground",children:s.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s.price})]},s.value)})})]}),e.jsxs("form",{onSubmit:D,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"reg-fullName",children:"Namn *"}),e.jsx(l,{id:"reg-fullName",value:p,onChange:s=>E(s.target.value),required:!0,maxLength:100,placeholder:"Förnamn Efternamn"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"reg-email",children:"E-post *"}),e.jsx(l,{id:"reg-email",type:"email",value:c,onChange:s=>P(s.target.value),required:!0,maxLength:255,placeholder:"[email protected]"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"reg-phone",children:"Telefon"}),e.jsx(l,{id:"reg-phone",type:"tel",value:j,onChange:s=>T(s.target.value),maxLength:30,placeholder:"070-123 45 67"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"reg-address",children:"Adress *"}),e.jsx(l,{id:"reg-address",value:f,onChange:s=>q(s.target.value),required:!0,maxLength:200,placeholder:"Gatuadress"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"reg-postal",children:"Postnummer *"}),e.jsx(l,{id:"reg-postal",value:m,onChange:s=>A(s.target.value),required:!0,maxLength:10,placeholder:"216 12"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"reg-city",children:"Ort *"}
1),e.jsx(l,{id:"reg-city",value:v,onChange:s=>B(s.target.value),required:!0,maxLength:100,placeholder:"Limhamn"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{htmlFor:"reg-password",children:"Lösenord *"}),e.jsx(l,{id:"reg-password",type:"password",value:y,onChange:s=>I(s.target.value),required:!0,minLength:8,placeholder:"Minst 8 tecken"})]}),b&&e.jsx("p",{className:"text-sm text-destructive",children:b}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Du ansöker som ",e.jsx("strong",{children:w.label})," (",w.price,"). Efter att styrelsen godkänt din ansökan får du betalningsinstruktioner."]}),e.jsxs(S,{type:"submit",size:"lg",className:"w-full rounded-full",disabled:N,children:[e.jsx(J,{className:"mr-2 h-4 w-4"}),N?"Skickar...":"Skicka ansökan"]}),e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Har du redan ett konto?"," ",e.jsx(L,{to:"/logga-in",className:"text-primary underline",children:"Logga in"})]})]})]})]})})};export{_ 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.