PageSourceSearch

https://www.abbeytheatre.co.uk/assets/MemberSignup-DYzyBw_K.js

js abbeytheatre.co.uk collected 2026-10-02 21:27:28 UTC 11,175 bytes, 1 lines download raw bytes

1import{k as Z,l as ee,r as c,q as x,s as f,j as e,S as se,H as M,a as O,F as U,C as y,c as g,d as b,n as Y,e as C,I as d,B as re,af as ne}from"./index-D6S94l3r.js";import{u as ie,F as te,a as i,b as t,c as o,d as a,e as p,f as B,t as oe}from"./form-BYqU0yUy.js";import{T as ae}from"./textarea-zkxjn3Pk.js";import{C as H}from"./checkbox-BuBNczcV.js";import{A as le,a as ce}from"./alert-BwV6f7kW.js";import{A as de,b as me,c as ue,d as he,e as pe,f as xe,g as fe,h as je}from"./alert-dialog-BuNtcri6.js";import{I as _e}from"./info-DyWOcR4x.js";import{o as ye,s as l}from"./types-DrUic4zr.js";const ge=ye({first_name:l().min(1,"First name is required"),last_name:l().min(1,"Last name is required"),email:l().email("Invalid email address"),phone:l().optional(),address_line_1:l().min(1,"Address is required"),address_line_2:l().optional(),city:l().min(1,"City is required"),county:l().optional(),post_code:l().min(1,"Post code is required"),country:l().default("United Kingdom"),theatre_groups:l().optional(),arts_interest:l().min(1,"Please tell us about your interest in the arts")});function De(){const{user:m,loading:j,membershipStatus:w}=Z(),_=ee(),[F,N]=c.useState(!1),[D,K]=c.useState([]),[P,I]=c.useState({}),[Q,v]=c.useState(!1),[W,T]=c.useState(!1),[h,$]=c.useState({first_name:"",last_name:"",phone:"",address_line_1:"",address_line_2:"",city:"",county:"",post_code:"",country:"United Kingdom"}),[k,G]=c.useState(!1),[E,S]=c.useState(!1),n=ie({resolver:oe(ge),defaultValues:{first_name:"",last_name:"",email:"",phone:"",address_line_1:"",address_line_2:"",city:"",county:"",post_code:"",country:"United Kingdom",theatre_groups:"",arts_interest:""}});c.useEffect(()=>{!j&&!m&&_("/auth?redirect=/member-signup")},[m,j,_]),c.useEffect(()=>{!j&&w==="approved"?_("/members"):!j&&w==="pending"&&(x.info("Your membership application is already pending review"),_("/"))},[j,w,_]),c.useEffect(()=>{m&&(J(),R())},[m]);const J=async()=>{const{data:s}=await f.from("user_profiles").select("first_name, last_name, email, phone, address_line_1, address_line_2, city, county, post_code, country").eq("id",m.id).single();if(s){const r={first_name:s.first_name||"",last_name:s.last_name||"",phone:s.phone||"",address_line_1:s.address_line_1||"",address_line_2:s.address_line_2||"",city:s.city||"",county:s.county||"",post_code:s.post_code||"",country:s.country||"United Kingdom"};$(r),n.reset({first_name:r.first_name,last_name:r.last_name,email:s.email,phone:r.phone,address_line_1:r.address_line_1,address_line_2:r.address_line_2,city:r.city,county:r.county,post_code:r.post_code,country:r.country,theatre_groups:"",arts_interest:""})}},R=async()=>{const{data:s}=await f.from("communication_preference_questions").select("id, question_text, description, display_order").eq("is_active",!0).order("display_order");if(s){K(s);const{data:r}=await f.from("user_communication_preferences").select("question_id, answer").eq("user_id",m.id),u={};s.forEach(A=>{const z=r?.find(X=>X.question_id===A.id);u[A.id]=z?.answer??!1}),I(u)}},q=s=>s.first_name!==h.first_name||s.last_name!==h.last_name||(s.phone||"")!==h.phone||s.address_line_1!==h.address_line_1||(s.address_line_2||"")!==h.address_line_2||s.city!==h.city||(s.county||"")!==h.county||s.post_code!==h.post_code||s.country!==h.country,L=async s=>{if(!k){S(!0),x.error("Please confirm your consent to apply for membership");return}if(S(!1),q(s)&&!W){v(!0);return}N(!0);try{if(q(s)){const{error:u}=await f.from("user_profiles").update({first_name:s.first_name,last_name:s.last_name,phone:s.phone||null,address_line_1:s.address_line_1,address_line_2:s.address_line_2||null,city:s.city,county:s.county||null,post_code:s.post_code,country:s.country}).eq("id",m.id);if(u){x.error("Failed to update profile"),N(!1);return}}const{error:r}=await f.from("membership_applications").insert({user_id:m.id,first_name:s.first_name,last_name:s.last_name,email:s.email,theatre_groups:s.theatre_groups||null,arts_interest:s.arts_interest,membership_consent:!0});if(r){r.code==="23505"?x.error("You have already submitted a membership application"):x.error("Failed to submit application"),N(!1);return}for(const[u,A]of Object.entries(P))await f.from("user_communication_preferences").upsert({user_id:m.id,question_id:u,answer:A},{onConflict:"user_id,question_id"});f.functions.invoke("send-signup-notification",{body:{type:"member",applicant_name:`${s.first_name} ${s.last_name}`}}
1).catch(u=>console.error("Failed to send member notification:",u)),x.success("Membership application submitted successfully!"),_("/")}catch{x.error("An error occurred. Please try again.")}finally{N(!1),T(!1)}},V=()=>{v(!1),T(!0),n.handleSubmit(L)()};return j?e.jsxs("div",{className:"min-h-screen flex flex-col bg-background",children:[e.jsx(se,{title:"Become a Member",description:"Become a member of The Abbey Theatre, Nuneaton and support community theatre while enjoying exclusive benefits."}),e.jsx(M,{}),e.jsx("main",{className:"flex-1 container mx-auto px-4 py-8 flex items-center justify-center",children:e.jsx(O,{className:"h-8 w-8 animate-spin"})}),e.jsx(U,{})]}):m?e.jsxs("div",{className:"min-h-screen flex flex-col bg-background",children:[e.jsx(M,{}),e.jsxs("main",{className:"flex-1 container mx-auto px-4 py-8 max-w-2xl",children:[e.jsx("h1",{className:"text-4xl font-bold mb-2",children:"Become a Member"}),e.jsx("p",{className:"text-muted-foreground mb-8",children:"Join Nuneaton Arts CIO and help support live theatre in our community."}),e.jsx(te,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(L),className:"space-y-8",children:[e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(b,{children:"Personal Details"}),e.jsx(Y,{children:"Some details have been pre-filled from your account."})]}),e.jsxs(C,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(i,{control:n.control,name:"first_name",render:({field:s})=>e.jsxs(t,{children:[e.jsx(o,{children:"First Name *"}),e.jsx(a,{children:e.jsx(d,{...s})}),e.jsx(p,{})]})}),e.jsx(i,{control:n.control,name:"last_name",render:({field:s})=>e.jsxs(t,{children:[e.jsx(o,{children:"Last Name *"}),e.jsx(a,{children:e.jsx(d,{...s})}),e.jsx(p,{})]})})]}),e.jsx(i,{control:n.control,name:"email",render:({field:s})=>e.jsxs(t,{children:[e.jsx(o,{children:"Email Address"}),e.jsx(a,{children:e.jsx(d,{...s,disabled:!0,className:"bg-muted"})}),e.jsx(B,{children:"This is your account email and cannot be changed here."})]})}),e.jsx(i,{control:n.control,name:"phone",render:({field:s})=>e.jsxs(t,{children:[e.jsx(o,{children:"Phone Number"}),e.jsx(a,{children:e.jsx(d,{...s,type:"tel"})}),e.jsx(p,{})]})})]})]}),e.jsxs(y,{children:[e.jsx(g,{children:e.jsx(b,{children:"Address"})}),e.jsxs(C,{className:"space-y-4",children:[e.jsxs(le,{children:[e.jsx(_e,{className:"h-4 w-4"}),e.jsx(ce,{children:"Address details are stored in your profile. Changes made here will update your profile across the site."})]}),e.jsx(i,{control:n.control,name:"address_line_1",render:({field:s})=>e.jsxs(t,{children:[e.jsx(o,{children:"Address Line 1 *"}),e.jsx(a,{children:e.jsx(d,{...s})}),e.jsx(p,{})]})}),e.jsx(i,{control:n.control,name:"address_line_2",render:({field:s})=>e.jsxs(t,{children:[e.jsx(o,{children:"Address Line 2"}),e.jsx(a,{children:e.jsx(d,{...s})})]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(i,{control:n.control,name:"city",render:({field:s})=>e.jsxs(t,{children:[e.jsx(o,{children:"City *"}),e.jsx(a,{children:e.jsx(d,{...s})}),e.jsx(p,{})]})}),e.jsx(i,{control:n.control,name:"county",render:({field:s})=>e.jsxs(t,{children:[e.jsx(o,{children:"County"}),e.jsx(a,{children:e.jsx(d,{...s})})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(i,{control:n.control,name:"post_code",render:({field:s})=>e.jsxs(t,{children:[e.jsx(o,{children:"Post Code *"}),e.jsx(a,{children:e.jsx(d,{...s})}),e.jsx(p,{})]})}),e.jsx(i,{control:n.control,name:"country",render:({field:s})=>e.jsxs(t,{children:[e.jsx(o,{children:"Country *"}),e.jsx(a,{children:e.jsx(d,{...s})}),e.jsx(p,{})]})})]})]})]}),e.jsxs(y,{children:[e.jsx(g,{children:e.jsx(b,{children:"About You"})}),e.jsxs(C,{className:"space-y-4",children:[e.jsx(i,{control:n.control,name:"theatre_groups",render:({field:s})=>e.jsxs(t,{children:[e.jsx(o,{children:"Theatre Groups"}),e.jsx(a,{children:e.jsx(d,{...s,placeholder:"Any theatre groups you're a member of"})}),e.jsx(B,{children:"List any theatre groups or societies you belong to."})]})}),e.jsx(i,{control:n.control,name:"arts_interest",render:({field:s})=>e.jsxs(t,{children:[e.jsx(o,{children:"Your Interest in the Arts *"}),e.jsx(a,{children:e.jsx(ae,{...s,placeholder:"Tell us about your interest in theatre and the arts...",rows:4})}),e.jsx(p,{})]})})]})]}),D.length>0&&e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(b,{children:"Communication Preferences"}),e.jsx(Y,{children:"Let us know how you'd like to hear from us."})]}),e.jsx(C,{className:"space-y-4",children:D.map(s=>e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx(H,{id:s.id,checked:P[s.id]||!1,onCheckedChange:r=>{I(u=>({...u,[s.id]:r===!0}))}}),e.jsxs("div",{className:"grid gap-1.5 leading-none",children:[e.jsx("label",{htmlFor:s.id,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer",children:s.question_text}),s.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:s.description})]})]},s.id))})]}),e.jsxs(y,{className:E?"border-destructive":"",children:[e.jsx(g,{children:e.jsx(b,{children:"Membership Consent *"})}),e.jsxs(C,{children:[e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx(H,{id:"membership-consent",checked:k,onCheckedChange:s=>{G(s===!0),s&&S(!1)}}),e.jsx("label",{htmlFor:"membership-consent",className:"text-sm leading-relaxed cursor-pointer",children:"I would like to apply for membership of the Nuneaton Arts CIO. I understand that the information provided in this form will be retained and used only for the purposes directly connected to my membership, in accordance with Nuneaton Arts CIO's Data Privacy Notice and I consent to Nuneaton Arts CIO using my email address to contact me regarding membership and meetings."})]}),E&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:"You must consent to the above to submit your application."})]})]}),e.jsx(re,{type:"submit",className:"w-full",disabled:F,children:F?e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"mr-2 h-4 w-4 animate-spin"}),"Submitting..."]}):"Submit Application"})]})})]}),e.jsx(U,{}),e.jsx(de,{open:Q,onOpenChange:v,children:e.jsxs(me,{children:[e.jsxs(ue,{children:[e.jsxs(he,{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-5 w-5 text-amber-500"}),"Update Profile Information?"]}),e.jsx(pe,{children:"You've made changes to your profile information (name, phone, or address). These changes will be saved to your profile and will appear across the entire site (My Account, future applications, etc.)"})]}),e.jsxs(xe,{children:[e.jsx(fe,{children:"Cancel"}),e.jsx(je,{onClick:V,children:"Update Profile & Submit"})]})]})})]}):null}export{De 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.