1import{r as t,u as F,v as P,j as e,B as h,s as U}from"./index-DQZClZTx.js";import{I as u}from"./input-BqYCZ2TY.js";import{L as n}from"./label-BoaK9F5G.js";import{T as k}from"./textarea-CfrYuH88.js";import{C as x,a as b,b as p,c as f,d as j}from"./card-BMOSh17R.js";import{L as q}from"./loader-circle-CJ0ktQyP.js";const D=()=>{const[o,v]=t.useState(""),[l,g]=t.useState(""),[c,y]=t.useState(""),[m,N]=t.useState(""),[r,d]=t.useState(!1),[C,w]=t.useState(!1),{toast:i}=F(),S=P(),E=async s=>{if(s.preventDefault(),!o.trim()){i({title:"Name required",description:"Please enter your full name",variant:"destructive"});return}if(!l.trim()&&!c.trim()){i({title:"Contact required",description:"Please provide at least your email or phone number",variant:"destructive"});return}d(!0);try{const{error:a}=await U.functions.invoke("process-unsubscribe",{body:{fullName:o.trim(),email:l.trim()||void 0,phone:c.trim()||void 0,reason:m.trim()||void 0}});if(a)throw a;w(!0),i({title:"Unsubscribe successful",description:"You have been removed from our communications list."})}catch(a){console.error("Error processing unsubscribe:",a),i({title:"Error",description:a.message||"Failed to process your request. Please try again.",variant:"destructive"})}finally{d(!1)}};return C?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-b from-background to-muted p-4",children:e.jsxs(x,{className:"w-full max-w-md",children:[e.jsxs(b,{className:"text-center",children:[e.jsx(p,{className:"text-2xl",children:"You've Been Unsubscribed"}),e.jsx(f,{className:"text-base mt-4",children:"You will no longer receive emails or text messages from us. We're sorry to see you go."})]}),e.jsx(j,{className:"text-center",children:e.jsx(h,{onClick:()=>S("/"),className:"mt-4",children:"Return to Homepage"})})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-b from-background to-muted p-4",children:e.jsxs(x,{className:"w-full max-w-md",children:[e.jsxs(b,{children:[e.jsx(p,{className:"text-2xl",children:"Unsubscribe"}),e.jsx(f,{children:"We're sorry to see you go. Please fill out the form below to unsubscribe from our emails and text messages."})]}),e.jsx(j,{children:e.jsxs("form",{onSubmit:E,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(n,{htmlFor:"fullName",children:"Full Name *"}),e.jsx(u,{id:"fullName",value:o,onChange:s=>v(s.target.value),placeholder:"Enter your full name",required:!0,disabled:r})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"email",children:"Email Address *"}),e.jsx(u,{id:"email",type:"email",value:l,onChange:s=>g(s.target.value),placeholder:"Enter your email address",required:!0,disabled:r})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"phone",children:"Phone Number (Optional)"}),e.jsx(u,{id:"phone",type:"tel",value:c,onChange:s=>y(s.target.value),placeholder:"Enter your phone number",disabled:r})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"reason",children:"Reason for Unsubscribing (Optional)"}),e.jsx(k,{id:"reason",value:m,onChange:s=>N(s.target.value),placeholder:"Let us know why you're unsubscribing",rows:4,disabled:r})]}),e.jsx(h,{type:"submit",className:"w-full",disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"mr-2 h-4 w-4 animate-spin"}),"Processing..."]}):"Unsubscribe"})]})})]})})};export{D 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.