1import{d as a,j as e,p as D,H as P,s as U,aj as H}from"./index-70yz1Rcc.js";const T=[{value:"sunday",label:"Sunday"},{value:"monday",label:"Monday"},{value:"other_weekday",label:"Another weekday"},{value:"saturday",label:"Saturday"},{value:"no_preference",label:"It varies / no preference"}],E=[{value:"10:00",label:"Morning â 10:00 AM UK"},{value:"13:00",label:"Early afternoon â 1:00 PM UK"},{value:"16:00",label:"Late afternoon â 4:00 PM UK"},{value:"18:00",label:"Evening â 6:00 PM UK"},{value:"19:00",label:"Later evening â 7:00 PM UK"},{value:"other",label:"Other"}],Y=[{value:"yes",label:"Yes, definitely"},{value:"maybe",label:"Maybe"},{value:"no",label:"Not really"}];function p({selected:r,onClick:c,children:o}){return e.jsxs("button",{type:"button",onClick:c,"aria-pressed":r,className:`flex w-full items-center gap-3 rounded-2xl border px-4 py-3.5 text-start text-[15px] leading-snug transition ${r?"border-[var(--gold)] bg-[var(--gold)]/12 text-foreground":"border-border bg-card text-foreground/90 hover:border-[var(--gold)]/60"}`,children:[e.jsx("span",{"aria-hidden":!0,className:`flex h-5 w-5 shrink-0 items-center justify-center rounded-md border ${r?"border-[var(--gold)] bg-[var(--gold)] text-background":"border-border bg-background"}`,children:r&&e.jsx(H,{className:"h-3.5 w-3.5"})}),o]})}function I(){const[r,c]=a.useState([]),[o,f]=a.useState([]),[g,v]=a.useState(null),[y,w]=a.useState(""),[j,k]=a.useState(!1),[K,N]=a.useState(!1),[S,m]=a.useState(null),[L,x]=a.useState(!0),n=a.useMemo(()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("t"),[]);a.useEffect(()=>{let s=!1;async function l(){if(!n){x(!1),m("This link is missing its personal code. Please open the link from your email again.");return}const t=new URLSearchParams(window.location.search),i=t.get("day"),h=t.get("time"),b=t.get("yoga"),{data:A}=await U.rpc("get_live_session_survey",{_token:n});if(s)return;const d=A??null;if(!d){m("We could not find this invitation. Please open the link from your email again, or reply to us and we will resend it."),x(!1);return}const C=new Set(d.days??[]);i&&T.some(u=>u.value===i)&&C.add(i);const M=new Set(d.times??[]);h&&E.some(u=>u.value===h)&&M.add(h),c([...C]),f([...M]),v(b&&Y.some(u=>u.value===b)?b:d.yoga_interest??null),w(d.suggestion??""),x(!1)}return l(),()=>{s=!0}},[n]);function _(s,l,t){l(s.includes(t)?s.filter(i=>i!==t):[...s,t])}async function W(){if(!n)return;k(!0),m(null);const{data:s,error:l}=await U.rpc("submit_live_session_survey",{_token:n,_days:r,_times:o,_yoga:g??"",_suggestion:y});k(!1);const t=s?.ok;if(l||!t){m("Something went wrong saving your answers. Please try once more.");return}N(!0)}return L?e.jsx("div",{className:"flex min-h-[50vh] items-center justify-center",children:e.jsx(D,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):K?e.jsx("div",{className:"mx-auto max-w-lg px-4 py-16 text-center",children:e.jsxs("div",{className:"rounded-3xl border border-[var(--gold)]/40 bg-card p-8 shadow-sm",children:[e.jsx(P,{className:"mx-auto mb-4 h-8 w-8 text-[var(--gold-deep)]"}),e.jsx("h1",{className:"font-serif text-3xl text-foreground",children:"Thank you ð"}),e.jsx("p",{className:"mt-3 text-[15px] leading-relaxed text-muted-foreground",children:"Your answers are saved. They go straight into our scheduling for the live sessions â yoga, grounding practices and workshops. There is nothing else to do."}),e.jsx("button",{type:"button",onClick:()=>N(!1),className:"mt-6 text-sm text-muted-foreground underline",children:"Change my answers"})]})}):e.jsxs("div",{className:"mx-auto max-w-lg px-4 py-10",children:[e.jsxs("header",{className:"mb-8 text-center",children:[e.jsxs("div",{className:"mb-4 inline-flex items-center gap-2 rounded-full border border-border bg-card px-3 py-1 text-xs text-muted-foreground",children:[e.jsx(P,{className:"h-3.5 w-3.5"})," Under a minute"]}),e.jsx("h1",{className:"font-serif text-3xl leading-tight tracking-tight text-foreground md:text-4xl",children:"Which days and times suit you for live sessions?"}),e.jsx("p",{className:"mx-auto mt-3 max-w-md text-[15px] leading-relaxed text-muted-foreground",children:"We are planning more live yoga, grounding and nervous-system practices and workshops. You can choose as many options as work for you â all times are UK time."})]}),S&&e.jsx("div",{className:"mb-6 rounded-2xl border border-destructive/30 bg-destructive/5 p-4 text-sm text-foreground",children:S}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"mb-3 text-sm font-semibold uppercase tracking-wide text-muted-foreground",children:"Which day would work best for you?"}),e.jsx("div",{className:"grid gap-2",children:T.map(s=>e.jsx(p,{selected:r.includes(s.value),onClick:()=>
1_(r,c,s.value),children:s.label},s.value))})]}),e.jsxs("section",{className:"mb-8",children:[e.jsxs("h2",{className:"mb-3 text-sm font-semibold uppercase tracking-wide text-muted-foreground",children:["What time works best for you? ",e.jsx("span",{className:"normal-case",children:"(UK time)"})]}),e.jsx("div",{className:"grid gap-2",children:E.map(s=>e.jsx(p,{selected:o.includes(s.value),onClick:()=>_(o,f,s.value),children:s.label},s.value))})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"mb-3 text-sm font-semibold uppercase tracking-wide text-muted-foreground",children:"Would you be interested in live yoga / gentle trauma-informed movement?"}),e.jsx("div",{className:"grid gap-2",children:Y.map(s=>e.jsx(p,{selected:g===s.value,onClick:()=>v(g===s.value?null:s.value),children:s.label},s.value))})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"mb-3 text-sm font-semibold uppercase tracking-wide text-muted-foreground",children:"Anything you would particularly like us to offer? (optional)"}),e.jsx("textarea",{value:y,onChange:s=>w(s.target.value.slice(0,600)),rows:3,placeholder:"For example: gentle morning yoga, a boundaries workshop, a quiet co-regulation hourâ¦",className:"w-full rounded-2xl border border-border bg-card px-4 py-3 text-[15px] text-foreground outline-none focus:border-[var(--gold)]"})]}),e.jsx("button",{type:"button",onClick:W,disabled:j||!n,className:"w-full rounded-full bg-[var(--gold-deep)] px-6 py-4 text-base font-semibold text-background shadow-sm transition hover:opacity-90 disabled:opacity-50",children:j?"Savingâ¦":"Send my answers"}),e.jsx("p",{className:"mt-4 text-center text-xs leading-relaxed text-muted-foreground",children:"Your answers are only used to schedule live sessions. There is no pressure to attend anything you sign up to hear about."})]})}export{I as component}; 2//# sourceMappingURL=live-sessions-survey-26MMB6cQ.js.map
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.