1import{r as i,j as e,F as k,z as d}from"./index-DR5BtYFg.js";import{H as f,F as p}from"./Footer-DEyAflqn.js";import"./nav-Df3-WuPQ.js";const y={hero:{title:"Weekly Insights",subtitle:"Subscribe to receive weekly Torah insights and inspiration"},form:{firstNameLabel:"First Name *",lastNameLabel:"Last Name *",emailLabel:"To subscribe to the Insights weekly email please enter your email below *",submitButtonText:"Submit",submittingText:"Submitting..."},success:{successHeading:"Successfully Subscribed!",successMessage:"Thank you for subscribing to our weekly Insights email. You'll receive Torah insights and inspiration directly to your inbox.",subscribeAnotherText:"Subscribe Another Person"}};function F(){const[j,N]=i.useState(y),[o,u]=i.useState({firstName:"",lastName:"",email:""}),[x,b]=i.useState(!1),[w,h]=i.useState(!1);i.useEffect(()=>{(async()=>{try{const s=await fetch("/api/pages/community/insights");if(s.ok){const t=await s.json();if(t.sections&&t.sections.length>0){const r={...y};t.sections.forEach(a=>{if(a.sectionKey&&a.content)switch(a.sectionKey){case"hero":r.hero={...r.hero,...a.content};break;case"form":r.form={...r.form,...a.content};break;case"success":r.success={...r.success,...a.content};break}}),N(r)}}}catch(s){console.error("Failed to fetch page content:",s)}})()},[]);const{hero:g,form:n,success:l}=j,m=c=>{const{name:s,value:t}=c.target;u(r=>({...r,[s]:t}))},v=async c=>{c.preventDefault(),b(!0);try{const t=await(await fetch("/api/forms/insights-signup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})).json();t.success?(d.success(t.message||"Successfully subscribed!"),h(!0),u({firstName:"",lastName:"",email:""})):d.error(t.error||"Failed to subscribe. Please try again.")}catch(s){console.error("Error submitting form:",s),d.error("An error occurred. Please try again later.")}finally{b(!1)}};return w?e.jsxs(e.Fragment,{children:[e.jsx(f,{}),e.jsx("div",{className:"min-h-screen bg-gray-50 py-12",children:e.jsx("div",{className:"max-w-2xl mx-auto px-8",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-lg p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("svg",{className:"w-8 h-8 text-green-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:l.successHeading}),e.jsx("p",{className:"text-gray-600 mb-6",children:l.successMessage}),e.jsx("button",{onClick:()=>h(!1),className:"bg-black text-white px-6 py-3 rounded-lg hover:bg-gray-800 transition-colors",children:l.subscribeAnotherText})]})})}),e.jsx(p,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(k,{position:"top-right"}),e.jsx(f,{}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("section",{className:"bg-black py-16",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-8 text-center",children:[e.jsx("h1",{className:"text-3xl md:text-5xl font-bold mb-6 text-white",children:g.title}),e.jsx("p",{className:"text-xl text-gray-300",children:g.subtitle})]})}),e.jsx("section",{className:"py-12",children:e.jsx("div",{className:"max-w-2xl mx-auto px-8",children:e.jsx("div",{className:"bg-white rounded-lg shadow-lg p-8",children:e.jsxs("form",{onSubmit:v,className:"space-y-6",children:[e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:n.firstNameLabel}),e.jsx("input",{type:"text",name:"firstName",value:o.firstName,onChange:m,required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-primary focus:border-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:n.lastNameLabel}),e.jsx("input",{type:"text",name:"lastName",value:o.lastName,onChange:m,required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-primary focus:border-primary"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:n.emailLabel}),e.jsx("input",{type:"email",name:"email",value:o.email,onChange:m,required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-primary focus:border-primary"})]}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"submit",disabled:x,className:"bg-black text-white px-8 py-3 rounded-lg hover:bg-gray-800 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:x?n.submittingText:n.submitButtonText})})]})})})})]}),e.jsx(p,{})]})}
1export{F 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.