PageSourceSearch

https://trovable.ai/assets/Unsubscribe-DQoNMooj.js

js trovable.ai collected 2026-10-05 13:49:09 UTC 3,435 bytes, 1 lines download raw bytes

1import{aK as j,r as n,s as u,j as e,al as g,ah as o,v as p,B as a,b8 as i,bC as l,aW as w}from"./index-CaerIkuo.js";function v(){const[d]=j(),s=d.get("token"),[t,r]=n.useState("loading"),[x,m]=n.useState("");n.useEffect(()=>{s?f():(r("error"),m("Invalid unsubscribe link"))},[s]);const f=async()=>{if(!s)return;if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s)){r("success");return}try{const{error:c}=await u.rpc("update_newsletter_subscription_by_token",{_token:s,_subscribed:!1});c&&console.error("Unsubscribe request error"),r("success")}catch{console.error("Unsubscribe request failed"),r("success")}},h=async()=>{if(!s)return;if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s)){r("resubscribed");return}try{await u.rpc("update_newsletter_subscription_by_token",{_token:s,_subscribed:!0}),r("resubscribed")}catch{console.error("Resubscribe request failed"),r("resubscribed")}};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(g,{}),e.jsx("main",{className:"container mx-auto px-4 py-8 pt-24 max-w-lg",children:e.jsxs("div",{className:"text-center space-y-6",children:[t==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-muted flex items-center justify-center",children:e.jsx(o,{className:"w-8 h-8 text-muted-foreground animate-pulse"})}),e.jsx("h1",{className:"text-2xl font-serif font-medium",children:"Processing..."}),e.jsx("p",{className:"text-muted-foreground",children:"Please wait while we update your preferences."})]}),t==="success"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-secondary flex items-center justify-center",children:e.jsx(p,{className:"w-8 h-8 text-accent"})}),e.jsx("h1",{className:"text-2xl font-serif font-medium",children:"You've been unsubscribed"}),e.jsx("p",{className:"text-muted-foreground",children:"You won't receive any more weekly digest emails from Trovable."}),e.jsxs("div",{className:"pt-4 space-y-3",children:[e.jsx(a,{variant:"outline",onClick:h,className:"w-full",children:"Changed your mind? Re-subscribe"}),e.jsx(i,{to:"/",children:e.jsxs(a,{variant:"ghost",className:"w-full gap-2",children:[e.jsx(l,{className:"w-4 h-4"}),"Back to Trovable"]})})]})]}),t==="resubscribed"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-accent/10 flex items-center justify-center",children:e.jsx(o,{className:"w-8 h-8 text-accent"})}),e.jsx("h1",{className:"text-2xl font-serif font-medium",children:"Welcome back!"}),e.jsx("p",{className:"text-muted-foreground",children:"You've been re-subscribed to the weekly digest. See you next Sunday!"}),e.jsx("div",{className:"pt-4",children:e.jsx(i,{to:"/",children:e.jsxs(a,{className:"w-full gap-2",children:[e.jsx(l,{className:"w-4 h-4"}),"Back to Trovable"]})})})]}),t==="error"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(w,{className:"w-8 h-8 text-destructive"})}),e.jsx("h1",{className:"text-2xl font-serif font-medium",children:"Something went wrong"}),e.jsx("p",{className:"text-muted-foreground",children:x}),e.jsx("div",{className:"pt-4",children:e.jsx(i,{to:"/",children:e.jsxs(a,{variant:"outline",className:"w-full gap-2",children:[e.jsx(l,{className:"w-4 h-4"}),"Back to Trovable"]})})})]})]})})]})}export{v 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.